結果
問題 | No.732 3PrimeCounting |
ユーザー | onakasuitacity |
提出日時 | 2020-10-17 14:50:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,806 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 272,192 KB |
最終ジャッジ日時 | 2024-07-21 02:29:04 |
合計ジャッジ時間 | 19,629 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,952 KB |
testcase_01 | AC | 40 ms
53,032 KB |
testcase_02 | AC | 39 ms
53,624 KB |
testcase_03 | AC | 39 ms
52,948 KB |
testcase_04 | AC | 40 ms
54,040 KB |
testcase_05 | AC | 44 ms
53,668 KB |
testcase_06 | AC | 47 ms
63,060 KB |
testcase_07 | AC | 47 ms
62,808 KB |
testcase_08 | AC | 47 ms
62,604 KB |
testcase_09 | AC | 47 ms
61,736 KB |
testcase_10 | AC | 47 ms
61,708 KB |
testcase_11 | AC | 46 ms
60,992 KB |
testcase_12 | AC | 47 ms
61,292 KB |
testcase_13 | AC | 47 ms
60,684 KB |
testcase_14 | AC | 47 ms
62,116 KB |
testcase_15 | AC | 48 ms
61,432 KB |
testcase_16 | AC | 49 ms
61,784 KB |
testcase_17 | AC | 48 ms
61,812 KB |
testcase_18 | AC | 49 ms
62,596 KB |
testcase_19 | AC | 46 ms
61,476 KB |
testcase_20 | AC | 56 ms
69,860 KB |
testcase_21 | AC | 75 ms
76,588 KB |
testcase_22 | AC | 75 ms
76,052 KB |
testcase_23 | AC | 51 ms
66,156 KB |
testcase_24 | AC | 53 ms
66,048 KB |
testcase_25 | AC | 90 ms
78,024 KB |
testcase_26 | AC | 86 ms
78,284 KB |
testcase_27 | AC | 62 ms
74,428 KB |
testcase_28 | AC | 63 ms
74,048 KB |
testcase_29 | AC | 72 ms
76,020 KB |
testcase_30 | AC | 73 ms
76,612 KB |
testcase_31 | AC | 75 ms
76,168 KB |
testcase_32 | AC | 83 ms
77,868 KB |
testcase_33 | AC | 83 ms
77,816 KB |
testcase_34 | AC | 86 ms
77,724 KB |
testcase_35 | AC | 84 ms
78,032 KB |
testcase_36 | AC | 85 ms
77,920 KB |
testcase_37 | AC | 54 ms
67,976 KB |
testcase_38 | AC | 55 ms
67,116 KB |
testcase_39 | AC | 88 ms
78,140 KB |
testcase_40 | AC | 76 ms
76,244 KB |
testcase_41 | AC | 74 ms
76,236 KB |
testcase_42 | AC | 73 ms
76,320 KB |
testcase_43 | AC | 75 ms
76,612 KB |
testcase_44 | AC | 74 ms
76,216 KB |
testcase_45 | AC | 68 ms
75,928 KB |
testcase_46 | AC | 68 ms
76,196 KB |
testcase_47 | AC | 73 ms
76,252 KB |
testcase_48 | AC | 90 ms
77,872 KB |
testcase_49 | AC | 89 ms
77,924 KB |
testcase_50 | AC | 76 ms
76,256 KB |
testcase_51 | AC | 75 ms
76,260 KB |
testcase_52 | AC | 63 ms
74,216 KB |
testcase_53 | AC | 126 ms
96,320 KB |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | AC | 176 ms
106,868 KB |
testcase_58 | AC | 177 ms
106,660 KB |
testcase_59 | AC | 123 ms
96,792 KB |
testcase_60 | AC | 253 ms
127,208 KB |
testcase_61 | AC | 252 ms
127,208 KB |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | AC | 51 ms
64,936 KB |
testcase_67 | AC | 51 ms
64,328 KB |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | AC | 87 ms
78,036 KB |
testcase_76 | WA | - |
testcase_77 | AC | 178 ms
106,060 KB |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | AC | 62 ms
73,664 KB |
testcase_83 | AC | 179 ms
105,868 KB |
testcase_84 | AC | 257 ms
129,944 KB |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
ソースコード
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() prime = 998244353 root = 3 def _fmt(A, inverse = False): N = len(A) logN = (N - 1).bit_length() base = pow(root, (prime - 1) // N * (1 - 2 * inverse) % (prime - 1), prime) step = N for k in range(logN): step >>= 1 w = pow(base, step, prime) wj = 1 nA = [0] * N for j in range(1 << k): for i in range(1 << logN - k - 1): s, t = i + j * step, i + j * step + (N >> 1) ps, pt = i + j * step * 2, i + j * step * 2 + step nA[s], nA[t] = (A[ps] + A[pt] * wj) % prime, (A[ps] - A[pt] * wj) % prime wj = (wj * w) % prime A = nA return A def convolution(f, g): N = 1 << (len(f) + len(g) - 2).bit_length() Ff, Fg = _fmt(f + [0] * (N - len(f))), _fmt(g + [0] * (N - len(g))) N_inv = pow(N, prime - 2, prime) fg = _fmt([a * b % prime * N_inv % prime for a, b in zip(Ff, Fg)], inverse = True) del fg[len(f) + len(g) - 1:] return fg def resolve(): n = int(input()) N = 3 * n primes = [] sieve = list(range(N + 1)) for i in range(2, N + 1): if sieve[i] == i: primes.append(i) for p in primes: if sieve[i] < p or i * p > N: break sieve[i * p] = p f = [0] * (n + 1) g = [0] * (2 * n + 1) for p in primes: if p <= n: f[p] += 1 g[p * 2] += 1 a = 0 f3 = convolution(f, convolution(f, f)) for p in primes: a += f3[p] b = 0 fg = convolution(f, g) for p in primes: b += fg[p] ans = (a - 3 * b) * pow(6, MOD - 2, MOD) % MOD print(ans) resolve()