結果
問題 | No.1387 Mitarushi's Remodeling |
ユーザー | Mitarushi |
提出日時 | 2021-01-19 22:53:15 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,836 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 235,356 KB |
最終ジャッジ日時 | 2024-06-29 22:59:47 |
合計ジャッジ時間 | 55,065 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
102,656 KB |
testcase_01 | AC | 90 ms
102,784 KB |
testcase_02 | AC | 90 ms
102,656 KB |
testcase_03 | AC | 90 ms
102,656 KB |
testcase_04 | AC | 91 ms
102,528 KB |
testcase_05 | AC | 91 ms
102,912 KB |
testcase_06 | AC | 91 ms
102,400 KB |
testcase_07 | AC | 90 ms
102,400 KB |
testcase_08 | AC | 141 ms
112,256 KB |
testcase_09 | AC | 137 ms
112,384 KB |
testcase_10 | AC | 143 ms
112,384 KB |
testcase_11 | AC | 142 ms
112,384 KB |
testcase_12 | AC | 141 ms
112,256 KB |
testcase_13 | AC | 142 ms
112,384 KB |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
ソースコード
mod = 998244353 max_kai = 4*10**5 kai = [1] for i in range(1, max_kai): kai.append(kai[-1] * i % mod) kkai = [0] * max_kai kkai[-1] = pow(kai[-1], mod - 2, mod) for i in reversed(range(1, max_kai)): kkai[i - 1] = kkai[i] * i % mod kkai_sum = [0]*(max_kai+1) for i in range(max_kai): kkai_sum[i+1] = (kkai_sum[i] + kkai[i]) % mod def cutsum(a, b): return kkai_sum[a] - kkai_sum[max(0, b)] 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], a[k] = (a[j]+a[k]) % mod, (a[j]-a[k])*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 a[k] *= w[s*t] a[j], a[k] = (a[j]+a[k]) % mod, (a[j]-a[k]) % mod m <<= 1 t //= 2 n_inv = pow(n, mod-2, mod) for i in range(n): a[i] = a[i] * n_inv % mod def convolution(a, b): n2 = max(len(a) + len(b), 1) n = 1 << (n2-1).bit_length() a = a + [0] * (n-len(a)) b = b + [0] * (n-len(b)) w_root = pow(3, (mod-1)//n, mod) w = [1] * n for i in range(1, n): w[i] = w[i-1] * w_root % mod fft_inplace(a, w) fft_inplace(b, w) c = [i*j % mod for i, j in zip(a, b)] ifft_inplace(c, w) return c[:n2] n, k = map(int, input().split()) m = [int(i)+1 for i in input().split()] b = convolution(m, m[::-1]) ans = 0 for i in range(n): ans += b[i] * (kai[n-1] * cutsum(n-1, n-k-1) - kai[i]*cutsum(i, i-k)) ans %= mod for i in m: ans *= i-1 ans %= mod ans *= pow(4, mod-2, mod) ans %= mod print(ans)