Submit Info #47388

Problem Lang User Status Time Memory
Polynomial Taylor Shift pypy3 convexineq AC 586 ms 151.41 MiB

ケース詳細
Name Status Time Memory
example_00 AC 69 ms 45.31 MiB
example_01 AC 69 ms 45.32 MiB
fft_killer_00 AC 584 ms 148.38 MiB
fft_killer_01 AC 585 ms 148.42 MiB
max_random_00 AC 585 ms 151.41 MiB
max_random_01 AC 586 ms 151.41 MiB
medium_00 AC 96 ms 46.88 MiB
medium_01 AC 101 ms 46.93 MiB
medium_02 AC 96 ms 46.81 MiB
medium_all_zero_00 AC 98 ms 46.97 MiB
medium_c_zero_00 AC 97 ms 46.81 MiB
random_00 AC 568 ms 130.50 MiB
random_01 AC 564 ms 137.41 MiB
random_02 AC 143 ms 57.54 MiB
small_00 AC 70 ms 45.26 MiB
small_01 AC 70 ms 45.26 MiB
small_02 AC 66 ms 45.21 MiB
small_03 AC 75 ms 45.31 MiB
small_04 AC 69 ms 45.32 MiB
small_05 AC 67 ms 45.27 MiB
small_06 AC 70 ms 45.30 MiB
small_07 AC 70 ms 45.26 MiB
small_08 AC 68 ms 45.30 MiB
small_09 AC 71 ms 45.30 MiB
small_10 AC 72 ms 45.23 MiB
small_11 AC 70 ms 45.30 MiB
small_12 AC 68 ms 45.31 MiB
small_13 AC 72 ms 45.31 MiB
small_14 AC 71 ms 45.34 MiB
small_15 AC 71 ms 45.35 MiB

SIZE=10**6+1 MOD = 998244353 ROOT = 3 roots = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根 iroots = [pow(x,MOD-2,MOD) for x in roots] # 1 の 2^i 乗根の逆元 def untt(a,n): for i in range(n): m = 1<<(n-i-1) for s in range(1<<i): w_N = 1 s *= m*2 for p in range(m): a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m])%MOD, (a[s+p]-a[s+p+m])*w_N%MOD w_N = w_N*roots[n-i]%MOD def iuntt(a,n): for i in range(n): m = 1<<i for s in range(1<<(n-i-1)): w_N = 1 s *= m*2 for p in range(m): a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m]*w_N)%MOD, (a[s+p]-a[s+p+m]*w_N)%MOD w_N = w_N*iroots[i+1]%MOD inv = pow((MOD+1)//2,n,MOD) for i in range(1<<n): a[i] = a[i]*inv%MOD def convolution(a,b): la = len(a) lb = len(b) if min(la, lb) <= 50: if la < lb: la,lb = lb,la a,b = b,a res = [0]*(la+lb-1) for i in range(la): for j in range(lb): res[i+j] += a[i]*b[j] res[i+j] %= MOD return res deg = la+lb-2 n = deg.bit_length() N = 1<<n a += [0]*(N-len(a)) b += [0]*(N-len(b)) untt(a,n) untt(b,n) for i in range(N): a[i] = a[i]*b[i]%MOD iuntt(a,n) return a[:deg+1] #inv = [0]*SIZE # inv[j] = j^{-1} mod MOD fac = [0]*SIZE # fac[j] = j! mod MOD finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 for i in range(2,SIZE): fac[i] = fac[i-1]*i%MOD finv[-1] = pow(fac[-1],MOD-2,MOD) for i in range(SIZE-1,0,-1): finv[i-1] = finv[i]*i%MOD #inv[i] = finv[i]*fac[i-1]%MOD def polynomial_Taylor_shift(f,c): N = len(f) f = f[:] g = [1]*N cc = c for i in range(1,N): f[i] = f[i]*fac[i]%MOD g[N-i-1] = cc*finv[i]%MOD cc = cc*c%MOD h = convolution(f,g)[N-1:] for i in range(N): h[i] = h[i]*finv[i]%MOD return h ############################################################### import sys readline = sys.stdin.readline n,c = map(int,readline().split()) *a, = map(int,readline().split()) ans = polynomial_Taylor_shift(a,c) print(*ans)