結果
問題 | No.1856 Mex Sum 2 |
ユーザー | Mitarushi |
提出日時 | 2021-04-17 17:51:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,325 ms / 3,000 ms |
コード長 | 1,802 bytes |
コンパイル時間 | 156 ms |
コンパイル使用メモリ | 82,260 KB |
実行使用メモリ | 77,560 KB |
最終ジャッジ日時 | 2024-07-04 04:46:03 |
合計ジャッジ時間 | 38,515 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
53,440 KB |
testcase_01 | AC | 37 ms
52,740 KB |
testcase_02 | AC | 77 ms
76,436 KB |
testcase_03 | AC | 37 ms
53,388 KB |
testcase_04 | AC | 58 ms
67,268 KB |
testcase_05 | AC | 58 ms
66,864 KB |
testcase_06 | AC | 53 ms
66,320 KB |
testcase_07 | AC | 64 ms
73,672 KB |
testcase_08 | AC | 38 ms
54,688 KB |
testcase_09 | AC | 51 ms
64,032 KB |
testcase_10 | AC | 55 ms
65,776 KB |
testcase_11 | AC | 55 ms
66,112 KB |
testcase_12 | AC | 45 ms
60,516 KB |
testcase_13 | AC | 38 ms
53,708 KB |
testcase_14 | AC | 37 ms
53,540 KB |
testcase_15 | AC | 37 ms
53,168 KB |
testcase_16 | AC | 54 ms
66,704 KB |
testcase_17 | AC | 75 ms
76,524 KB |
testcase_18 | AC | 73 ms
76,628 KB |
testcase_19 | AC | 55 ms
65,696 KB |
testcase_20 | AC | 54 ms
66,124 KB |
testcase_21 | AC | 39 ms
54,544 KB |
testcase_22 | AC | 73 ms
76,600 KB |
testcase_23 | AC | 38 ms
53,684 KB |
testcase_24 | AC | 61 ms
71,544 KB |
testcase_25 | AC | 72 ms
76,264 KB |
testcase_26 | AC | 37 ms
53,436 KB |
testcase_27 | AC | 37 ms
54,040 KB |
testcase_28 | AC | 39 ms
54,420 KB |
testcase_29 | AC | 381 ms
76,776 KB |
testcase_30 | AC | 253 ms
77,044 KB |
testcase_31 | AC | 369 ms
77,036 KB |
testcase_32 | AC | 517 ms
76,932 KB |
testcase_33 | AC | 528 ms
77,160 KB |
testcase_34 | AC | 372 ms
76,928 KB |
testcase_35 | AC | 268 ms
77,276 KB |
testcase_36 | AC | 167 ms
76,664 KB |
testcase_37 | AC | 366 ms
77,036 KB |
testcase_38 | AC | 146 ms
76,552 KB |
testcase_39 | AC | 97 ms
76,764 KB |
testcase_40 | AC | 98 ms
76,544 KB |
testcase_41 | AC | 101 ms
76,504 KB |
testcase_42 | AC | 1,265 ms
76,776 KB |
testcase_43 | AC | 1,144 ms
76,900 KB |
testcase_44 | AC | 1,196 ms
77,560 KB |
testcase_45 | AC | 1,252 ms
76,900 KB |
testcase_46 | AC | 1,146 ms
76,916 KB |
testcase_47 | AC | 1,204 ms
76,800 KB |
testcase_48 | AC | 1,276 ms
77,196 KB |
testcase_49 | AC | 1,270 ms
77,036 KB |
testcase_50 | AC | 1,029 ms
77,176 KB |
testcase_51 | AC | 1,293 ms
77,320 KB |
testcase_52 | AC | 1,282 ms
77,312 KB |
testcase_53 | AC | 1,293 ms
76,928 KB |
testcase_54 | AC | 1,287 ms
77,184 KB |
testcase_55 | AC | 1,297 ms
76,980 KB |
testcase_56 | AC | 1,299 ms
76,912 KB |
testcase_57 | AC | 1,293 ms
76,924 KB |
testcase_58 | AC | 1,302 ms
77,540 KB |
testcase_59 | AC | 1,293 ms
77,060 KB |
testcase_60 | AC | 1,305 ms
76,908 KB |
testcase_61 | AC | 1,286 ms
77,296 KB |
testcase_62 | AC | 1,289 ms
77,068 KB |
testcase_63 | AC | 1,282 ms
77,552 KB |
testcase_64 | AC | 1,289 ms
76,932 KB |
testcase_65 | AC | 1,325 ms
77,200 KB |
testcase_66 | AC | 1,284 ms
76,908 KB |
ソースコード
mod = 998244353 def fft_inplace(a, w): n = len(a) m = n t = 1 while m >= 2: mh = m >> 1 for i in range(0, n, m): for s in range(mh): j, k = i+s, i+mh+s a[j], u = a[j]+a[k], a[j]-a[k] a[k] = u * w[s*t] % mod m = mh t *= 2 def ifft_inplace(a, w): n = len(a) m = 2 t = -(n >> 1) while m <= n: mh = m >> 1 for i in range(0, n, m): for s in range(mh): j, k = i+s, i+mh+s u = a[k] * w[s*t] % mod a[j], a[k] = a[j]+u, a[j]-u m <<= 1 t //= 2 n_inv = pow(n, mod-2, mod) for i in range(n): a[i] = a[i] * n_inv % mod n, m = map(int, input().split()) fixed_n = 1 << ((n+1)*2).bit_length() w_root = pow(3, (mod-1)//fixed_n, mod) w = [1] * fixed_n for i in range(1, fixed_n): w[i] = w[i-1] * w_root % mod frac = [1] * (n + 1) for i in range(1, n+1): frac[i] = frac[i-1] * i % mod frac_inv = [0] * (n+1) frac_inv[n] = pow(frac[n], mod-2, mod) for i in range(1, n+1)[::-1]: frac_inv[i-1] = frac_inv[i] * i % mod dp1 = [0] * fixed_n dp1[0] = 1 t = [0] * fixed_n for i in range(n+1): t[i] = (pow(2, i, mod)-1) * pow(pow(2, i, mod) * frac[i], mod-2, mod) % mod fft_inplace(t, w) ans_sub = [0] * (n+1) for k in range(min(n, m+1)): fft_inplace(dp1, w) for i, j in enumerate(t): dp1[i] = dp1[i] * j % mod ifft_inplace(dp1, w) pow_tmp = 1 for i in range(k+1, n+1)[::-1]: ans_sub[i] += dp1[i] * pow_tmp % mod pow_tmp = pow_tmp * (m - k) % mod for i in range(n+1, fixed_n): dp1[i] = 0 ans = sum(ans_sub[i] % mod * frac_inv[n-i] for i in range(n+1)) % mod ans = ans * pow(2, n, mod) * frac[n] % mod print(ans)