标签:结果 putc name ons typename dig while 方法 就是
#include<bits/stdc++.h>
#define LL long long
#define MAXN 400000
#define MOD 1004535809
#define YG 3
using namespace std;
template<typename T>void Read(T &cn)
{
char c; int sig = 1;
while(!isdigit(c = getchar())) if(c == ‘-‘) sig = -1; cn = c-48;
while(isdigit(c = getchar())) cn = cn*10+c-48; cn*=sig;
}
template<typename T>void Read_m(T &cn)
{
char c;
while(!isdigit(c = getchar())); cn = c-48;
while(isdigit(c = getchar())) cn = (cn*10ll+c-48)%MOD;
}
template<typename T>void Write(T cn)
{
if(cn < 0) {putchar(‘-‘); cn = 0-cn; }
int wei = 0; T cm = 0; int cx = cn%10; cn/=10;
while(cn) wei++, cm = cm*10+cn%10, cn/=10;
while(wei--) putchar(cm%10+48), cm /= 10;
putchar(cx+48);
}
template<typename T>void Max(T &cn, T cm) {cn = cn < cm ? cm : cn; }
template<typename T>void Min(T &cn, T cm) {cn = cn < cm ? cn : cm; }
const int MAXNTT = MAXN*4+1;
int n, k, typ;
int a[MAXNTT], b[MAXNTT];
int omg[MAXNTT], inv[MAXNTT], fan[MAXNTT], Mn;
int erwei(int cn) {int guo = 0; while(cn) guo++, cn>>=1; return guo; }
LL ksm(LL cn, LL cm) {LL ans = 1; cn=cn%MOD; while(cm) ans = ans*(1+(cn-1)*(cm&1))%MOD, cn = cn*cn%MOD, cm>>=1; return ans; }
void yuchu(int cn)
{
Mn = 1<<erwei(cn);
omg[0] = inv[0] = 1;
omg[1] = ksm(YG, MOD/Mn); inv[1] = ksm(omg[1], MOD-2);
for(int i = 2;i<Mn;i++) omg[i] = 1ll*omg[i-1]*omg[1]%MOD, inv[i] = 1ll*inv[i-1]*inv[1]%MOD;
fan[0] = 0; int lin = erwei(Mn)-2;
for(int i = 1;i<Mn;i++) fan[i] = (fan[i>>1]>>1) | ((i&1)<<lin);
}
void ntt(int a[], int omg[], int n)
{
for(int i = 0;i<n;i++) a[i] = (a[i]%MOD+MOD)%MOD;
for(int i = 0;i<n;i++) if(fan[i] > i) swap(a[fan[i]], a[i]);
for(int i = 2, m = 1;i<=n;i = (m = i)<<1)
for(int j = 0;j<n;j+=i)
for(int k = 0;k<m;k++)
{
int lin1 = a[j+k], lin2 = 1ll*a[j+k+m]*omg[Mn/i*k]%MOD;
a[j+k] = lin1+lin2>=MOD ? lin1+lin2-MOD : lin1+lin2;
a[j+k+m] = lin1>=lin2 ? lin1-lin2 : lin1-lin2+MOD;
}
}
void yuchu_qian()
{
b[0] = 1;
for(int i = 1;i<n;i++) b[i] = 1ll*b[i-1]*(k+i-1)%MOD*ksm(i, MOD-2)%MOD;
}
void yuchu_cha()
{
b[0] = 1; int lin = min(k+1,n-1);
for(int i = 1;i<=lin;i++) b[i] = -1ll*b[i-1]*(k-i+1)%MOD*ksm(i, MOD-2)%MOD;
}
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
Read(n); Read_m(k); Read(typ);
for(int i = 0;i<n;i++) Read(a[i]);
if(typ == 0) yuchu_qian(); else yuchu_cha();
yuchu(n*2);
ntt(a, omg, Mn); ntt(b, omg, Mn);
for(int i = 0;i<Mn;i++) a[i] = 1ll*a[i]*b[i]%MOD;
ntt(a, inv, Mn); int lin = ksm(Mn, MOD-2);
for(int i = 0;i<Mn;i++) a[i] = 1ll*a[i]*lin%MOD;
for(int i = 0;i<n;i++) Write(a[i]), putchar(‘ ‘); puts("");
return 0;
}
标签:结果 putc name ons typename dig while 方法 就是
原文地址:https://www.cnblogs.com/czyarl/p/13054098.html