LL power(LL x, int p){ LL cnt = 1; while (p) { if (p & 1) cnt = cnt * x % MOD; x = x * x % MOD; p >>= 1; } return cnt; } const LL invg = power (g, MOD - 2);
int N; LL f[MAXN], invf[MAXN]= {0};
LL A[MAXN]= {0}, B[MAXN]= {0}; int oppo[MAXN]= {0}; int limit; voidNTT(LL* a, int inv){ for (int i = 0; i < limit; i ++) if (i < oppo[i]) swap (a[i], a[oppo[i]]); for (int mid = 1; mid < limit; mid <<= 1) { LL omega = power (inv == 1 ? g : invg, (MOD - 1) / (mid << 1)); for (int n = mid << 1, j = 0; j < limit; j += n) { LL x = 1; for (int k = 0; k < mid; k ++, x = x * omega % MOD) { LL a1 = a[j + k], xa2 = x * a[j + k + mid] % MOD; a[j + k] = (a1 + xa2) % MOD; a[j + k + mid] = (a1 - xa2 + MOD) % MOD; } } } } voidInverse(int deg, LL* ps){ if (deg == 1) { ps[0] = power (f[0], MOD - 2); return ; } Inverse ((deg + 1) >> 1, ps); int n, lim; for (n = 1, lim = 0; n < (deg << 1); n <<= 1, lim ++); limit = n; for (int i = 0; i < limit; i ++) oppo[i] = (oppo[i >> 1] >> 1) | ((i & 1) << (lim - 1)); for (int i = 0; i < limit; i ++) A[i] = B[i] = 0; for (int i = 0; i < deg; i ++) A[i] = f[i]; for (int i = 0; i < deg << 1; i ++) B[i] = ps[i]; NTT (A, 1), NTT (B, 1); for (int i = 0; i < limit; i ++) B[i] = B[i] * ((2ll - A[i] * B[i] % MOD + MOD) % MOD) % MOD; NTT (B, - 1); LL invn = power (n, MOD - 2); for (int i = 0; i < deg; i ++) ps[i] = B[i] * invn % MOD; }
intgetnum(){ int num = 0; char ch = getchar ();
while (! isdigit (ch)) ch = getchar (); while (isdigit (ch)) num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();
return num; }
intmain(){ N = getnum (); for (int i = 0; i < N; i ++) f[i] = getnum (); Inverse (N, invf); for (int i = 0; i < N; i ++) { if (i > 0) putchar (' '); printf ("%lld", invf[i]); } puts ("");