結果
問題 | No.1655 123 Swaps |
ユーザー | Kiri8128 |
提出日時 | 2021-06-25 02:26:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 398 ms / 2,000 ms |
コード長 | 2,439 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 135,808 KB |
最終ジャッジ日時 | 2024-10-14 02:15:27 |
合計ジャッジ時間 | 9,743 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
68,096 KB |
testcase_01 | AC | 61 ms
67,968 KB |
testcase_02 | AC | 76 ms
73,856 KB |
testcase_03 | AC | 62 ms
68,224 KB |
testcase_04 | AC | 62 ms
68,096 KB |
testcase_05 | AC | 62 ms
68,224 KB |
testcase_06 | AC | 62 ms
68,224 KB |
testcase_07 | AC | 66 ms
68,352 KB |
testcase_08 | AC | 61 ms
68,224 KB |
testcase_09 | AC | 62 ms
68,224 KB |
testcase_10 | AC | 68 ms
70,400 KB |
testcase_11 | AC | 64 ms
69,248 KB |
testcase_12 | AC | 66 ms
70,528 KB |
testcase_13 | AC | 63 ms
68,480 KB |
testcase_14 | AC | 62 ms
68,224 KB |
testcase_15 | AC | 395 ms
135,552 KB |
testcase_16 | AC | 395 ms
135,680 KB |
testcase_17 | AC | 397 ms
135,808 KB |
testcase_18 | AC | 396 ms
135,808 KB |
testcase_19 | AC | 392 ms
135,680 KB |
testcase_20 | AC | 397 ms
135,680 KB |
testcase_21 | AC | 398 ms
135,552 KB |
testcase_22 | AC | 394 ms
135,808 KB |
testcase_23 | AC | 390 ms
135,680 KB |
testcase_24 | AC | 391 ms
135,808 KB |
testcase_25 | AC | 391 ms
135,680 KB |
testcase_26 | AC | 383 ms
135,552 KB |
testcase_27 | AC | 239 ms
108,544 KB |
testcase_28 | AC | 237 ms
108,032 KB |
testcase_29 | AC | 391 ms
134,912 KB |
testcase_30 | AC | 396 ms
134,912 KB |
testcase_31 | AC | 235 ms
107,904 KB |
testcase_32 | AC | 62 ms
68,352 KB |
testcase_33 | AC | 61 ms
67,968 KB |
testcase_34 | AC | 62 ms
68,096 KB |
testcase_35 | AC | 61 ms
68,096 KB |
testcase_36 | AC | 77 ms
77,312 KB |
testcase_37 | AC | 78 ms
77,184 KB |
testcase_38 | AC | 77 ms
73,984 KB |
testcase_39 | AC | 92 ms
87,936 KB |
testcase_40 | AC | 390 ms
135,552 KB |
testcase_41 | AC | 61 ms
68,608 KB |
testcase_42 | AC | 62 ms
68,352 KB |
testcase_43 | AC | 61 ms
67,968 KB |
testcase_44 | AC | 64 ms
67,968 KB |
ソースコード
p, g, ig = 924844033, 5, 554906420 W = [pow(g, (p - 1) >> i, p) for i in range(24)] iW = [pow(ig, (p - 1) >> i, p) for i in range(24)] P = p nn = 600600 fa = [1] * (nn+1) fainv = [1] * (nn+1) for i in range(nn): fa[i+1] = fa[i] * (i+1) % P fainv[-1] = pow(fa[-1], P-2, P) for i in range(nn)[::-1]: fainv[i] = fainv[i+1] * (i+1) % P def convolve(a, b): def fft(f): for l in range(k, 0, -1): d = 1 << l - 1 U = [1] for i in range(d): U.append(U[-1] * W[l] % p) for i in range(1 << k - l): for j in range(d): s = i * 2 * d + j t = s + d f[s], f[t] = (f[s] + f[t]) % p, U[j] * (f[s] - f[t]) % p def ifft(f): for l in range(1, k + 1): d = 1 << l - 1 U = [1] for i in range(d): U.append(U[-1] * iW[l] % p) for i in range(1 << k - l): for j in range(d): s = i * 2 * d + j t = s + d f[s], f[t] = (f[s] + f[t] * U[j]) % p, (f[s] - f[t] * U[j]) % p n0 = len(a) + len(b) - 1 if len(a) < 50 or len(b) < 50: ret = [0] * n0 if len(a) > len(b): a, b = b, a for i, aa in enumerate(a): for j, bb in enumerate(b): ret[i+j] = (ret[i+j] + aa * bb) % p return ret k = (n0).bit_length() n = 1 << k a = a + [0] * (n - len(a)) b = b + [0] * (n - len(b)) fft(a), fft(b) for i in range(n): a[i] = a[i] * b[i] % p ifft(a) invn = pow(n, p - 2, p) for i in range(n0): a[i] = a[i] * invn % p del a[n0:] return a def calc(a, b, c): M = a + b + c if M % 2: return 0 M //= 2 i3 = pow(3, P - 2, P) re = 0 www = [1, 667811836, 257032196] # Cube root of 1 mod P A = [fainv[i] * fainv[a-i] % P * www[(2*i-a)%3] % P for i in range(a + 1)] B = [fainv[i] * fainv[b-i] % P * www[(b-2*i)%3] % P for i in range(b + 1)] AB = convolve(A, B) for i, x in enumerate(AB): if i > M: continue j = M - a - b + i if j < 0: continue re = (re + x * fainv[M-i] % P * fainv[j]) % P re = fa[M] ** 2 % P * re % P * 2 * i3 % P re = (re + fa[M*2] * fainv[a] * fainv[b] * fainv[c] * i3) % P return re a, b, c = map(int, input().split()) print(calc(a, b, c))