• loj#6261. 一个人的高三楼


    题意:求数组的k次前缀和,取模
    题解:ntt,构造k-1的前缀和,然后ntt,k-1次第i位的前缀和是C(k-1+i,i)

    //#pragma GCC optimize(2)
    //#pragma GCC optimize(3)
    //#pragma GCC optimize(4)
    //#pragma GCC optimize("unroll-loops")
    //#pragma comment(linker, "/stack:200000000")
    //#pragma GCC optimize("Ofast,no-stack-protector")
    //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define fi first
    #define se second
    #define db double
    #define mp make_pair
    #define pb push_back
    #define pi acos(-1.0)
    #define ll long long
    #define vi vector<int>
    #define mod 998244353
    #define ld long double
    //#define C 0.5772156649
    #define ls l,m,rt<<1
    #define rs m+1,r,rt<<1|1
    #define pll pair<ll,ll>
    #define pil pair<int,ll>
    #define pli pair<ll,int>
    #define pii pair<int,int>
    //#define cd complex<double>
    #define ull unsigned long long
    //#define base 1000000000000000000
    #define fin freopen("a.txt","r",stdin)
    #define fout freopen("a.txt","w",stdout)
    #define fio ios::sync_with_stdio(false);cin.tie(0)
    inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
    inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
    template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
    template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
    inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
    inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}
    
    using namespace std;
    
    const double eps=1e-8;
    const ll INF=0x3f3f3f3f3f3f3f3f;
    const int N=100000+10,maxn=200000+10,inf=0x3f3f3f3f;
    
    ll x[N<<3],y[N<<3];
    int rev[N<<3];
    void getrev(int bit)
    {
        for(int i=0;i<(1<<bit);i++)
            rev[i]=(rev[i>>1]>>1) | ((i&1)<<(bit-1));
    }
    void ntt(ll *a,int n,int dft)
    {
        for(int i=0;i<n;i++)
            if(i<rev[i])
                swap(a[i],a[rev[i]]);
        for(int step=1;step<n;step<<=1)
        {
            ll wn=qp(3,(mod-1)/(step*2));
            if(dft==-1)wn=qp(wn,mod-2);
            for(int j=0;j<n;j+=step<<1)
            {
                ll wnk=1;
                for(int k=j;k<j+step;k++)
                {
                    ll x=a[k];
                    ll y=wnk*a[k+step]%mod;
                    a[k]=(x+y)%mod;a[k+step]=(x-y+mod)%mod;
                    wnk=wnk*wn%mod;
                }
            }
        }
        if(dft==-1)
        {
            ll inv=qp(n,mod-2);
            for(int i=0;i<n;i++)a[i]=a[i]*inv%mod;
        }
    }
    int main()
    {
        int n;ll k;
        scanf("%d%lld",&n,&k);k%=mod;
        for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
        int sz=0;while((1<<sz)<n)sz++;sz++;
        getrev(sz);
        y[0]=1;
        for(int i=1;i<n;i++)y[i]=y[i-1]*(k+i-1)%mod*qp(i,mod-2)%mod;
        ntt(x,(1<<sz),1);ntt(y,(1<<sz),1);
        for(int i=0;i<(1<<sz);i++)x[i]=x[i]*y[i]%mod;
        ntt(x,(1<<sz),-1);
        for(int i=1;i<=n;i++)printf("%lld
    ",x[i]);
        return 0;
    }
    /********************
    
    ********************/
    
  • 相关阅读:
    BZOJ1880: [Sdoi2009]Elaxia的路线(最短路)
    「BZOJ1433」[ZJOI2009] 假期的宿舍(二分图,网络流)
    BZOJ 1061 [Noi2008]志愿者招募(费用流)
    [BZOJ2879][Noi2012]美食节(费用流)
    bzoj 1834 [ZJOI2010] network 网络扩容(费用流)
    BZOJ2668:[CQOI2012]交换棋子(费用流)
    bzoj1070【SCOI2007】修车(费用流)
    【BZOJ 1877】 [SDOI2009]晨跑(费用流)
    SQLite_Home
    GeoMesa-单机搭建
  • 原文地址:https://www.cnblogs.com/acjiumeng/p/10098704.html
Copyright © 2020-2023  润新知