結果
問題 | No.1100 Boxes |
ユーザー | convexineq |
提出日時 | 2021-05-11 18:21:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 270 ms / 2,000 ms |
コード長 | 2,223 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 87,988 KB |
最終ジャッジ日時 | 2024-09-22 01:05:43 |
合計ジャッジ時間 | 6,437 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
62,208 KB |
testcase_01 | AC | 53 ms
61,824 KB |
testcase_02 | AC | 53 ms
61,952 KB |
testcase_03 | AC | 62 ms
64,128 KB |
testcase_04 | AC | 54 ms
61,952 KB |
testcase_05 | AC | 55 ms
62,080 KB |
testcase_06 | AC | 54 ms
61,952 KB |
testcase_07 | AC | 53 ms
62,208 KB |
testcase_08 | AC | 53 ms
62,208 KB |
testcase_09 | AC | 54 ms
61,824 KB |
testcase_10 | AC | 53 ms
62,208 KB |
testcase_11 | AC | 54 ms
62,208 KB |
testcase_12 | AC | 53 ms
61,952 KB |
testcase_13 | AC | 54 ms
62,208 KB |
testcase_14 | AC | 60 ms
64,512 KB |
testcase_15 | AC | 61 ms
64,512 KB |
testcase_16 | AC | 61 ms
64,768 KB |
testcase_17 | AC | 75 ms
70,400 KB |
testcase_18 | AC | 73 ms
70,144 KB |
testcase_19 | AC | 86 ms
75,776 KB |
testcase_20 | AC | 103 ms
80,384 KB |
testcase_21 | AC | 157 ms
83,328 KB |
testcase_22 | AC | 237 ms
87,296 KB |
testcase_23 | AC | 160 ms
82,944 KB |
testcase_24 | AC | 169 ms
83,468 KB |
testcase_25 | AC | 171 ms
83,632 KB |
testcase_26 | AC | 251 ms
87,476 KB |
testcase_27 | AC | 249 ms
87,296 KB |
testcase_28 | AC | 127 ms
81,152 KB |
testcase_29 | AC | 260 ms
87,168 KB |
testcase_30 | AC | 250 ms
87,168 KB |
testcase_31 | AC | 135 ms
81,920 KB |
testcase_32 | AC | 189 ms
84,028 KB |
testcase_33 | AC | 270 ms
87,600 KB |
testcase_34 | AC | 258 ms
87,612 KB |
testcase_35 | AC | 53 ms
62,080 KB |
testcase_36 | AC | 213 ms
87,712 KB |
testcase_37 | AC | 54 ms
62,080 KB |
testcase_38 | AC | 166 ms
83,296 KB |
testcase_39 | AC | 251 ms
87,988 KB |
ソースコード
SIZE= 2*10**5+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 choose(n,r): # nCk mod MOD の計算 if 0 <= r <= n: return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD else: return 0 ############################################################### n,k = map(int,input().split()) a = [pow(i,n,MOD)*finv[i]%MOD for i in range(k+1)] b = finv[:k+1] for i in range(1,k+1,2): b[i] = -b[i] p = convolution(a,b)[:k+1] for i in range(k+1): p[i] = p[i]*fac[i]%MOD*choose(k,i)%MOD print(sum(p[(k-1)%2::2])%MOD)