結果
問題 | No.732 3PrimeCounting |
ユーザー | onakasuitacity |
提出日時 | 2020-10-17 14:51:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,794 bytes |
コンパイル時間 | 457 ms |
コンパイル使用メモリ | 82,100 KB |
実行使用メモリ | 272,296 KB |
最終ジャッジ日時 | 2024-07-21 02:29:32 |
合計ジャッジ時間 | 17,797 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,480 KB |
testcase_01 | AC | 38 ms
53,120 KB |
testcase_02 | AC | 38 ms
52,820 KB |
testcase_03 | AC | 39 ms
53,248 KB |
testcase_04 | AC | 40 ms
52,480 KB |
testcase_05 | AC | 39 ms
52,992 KB |
testcase_06 | AC | 47 ms
61,184 KB |
testcase_07 | AC | 47 ms
61,184 KB |
testcase_08 | AC | 46 ms
61,184 KB |
testcase_09 | AC | 48 ms
61,184 KB |
testcase_10 | AC | 48 ms
60,928 KB |
testcase_11 | AC | 47 ms
61,184 KB |
testcase_12 | AC | 46 ms
61,184 KB |
testcase_13 | AC | 47 ms
60,800 KB |
testcase_14 | AC | 46 ms
61,312 KB |
testcase_15 | AC | 45 ms
60,672 KB |
testcase_16 | AC | 46 ms
61,056 KB |
testcase_17 | AC | 47 ms
60,928 KB |
testcase_18 | AC | 45 ms
61,440 KB |
testcase_19 | AC | 46 ms
61,056 KB |
testcase_20 | AC | 57 ms
68,864 KB |
testcase_21 | AC | 74 ms
76,272 KB |
testcase_22 | AC | 75 ms
76,672 KB |
testcase_23 | AC | 52 ms
66,176 KB |
testcase_24 | AC | 51 ms
65,664 KB |
testcase_25 | AC | 86 ms
77,696 KB |
testcase_26 | AC | 84 ms
77,732 KB |
testcase_27 | AC | 61 ms
74,112 KB |
testcase_28 | AC | 62 ms
73,728 KB |
testcase_29 | AC | 72 ms
76,032 KB |
testcase_30 | AC | 71 ms
76,288 KB |
testcase_31 | AC | 74 ms
76,032 KB |
testcase_32 | AC | 82 ms
77,824 KB |
testcase_33 | AC | 86 ms
77,788 KB |
testcase_34 | AC | 84 ms
78,096 KB |
testcase_35 | AC | 83 ms
77,788 KB |
testcase_36 | AC | 82 ms
77,700 KB |
testcase_37 | AC | 54 ms
67,584 KB |
testcase_38 | AC | 53 ms
67,584 KB |
testcase_39 | AC | 85 ms
77,696 KB |
testcase_40 | AC | 73 ms
76,288 KB |
testcase_41 | AC | 73 ms
76,324 KB |
testcase_42 | AC | 72 ms
76,160 KB |
testcase_43 | AC | 73 ms
76,112 KB |
testcase_44 | AC | 73 ms
76,136 KB |
testcase_45 | AC | 68 ms
76,008 KB |
testcase_46 | AC | 66 ms
76,100 KB |
testcase_47 | AC | 72 ms
76,220 KB |
testcase_48 | AC | 86 ms
77,696 KB |
testcase_49 | AC | 86 ms
77,816 KB |
testcase_50 | AC | 75 ms
76,032 KB |
testcase_51 | AC | 73 ms
76,672 KB |
testcase_52 | AC | 64 ms
73,984 KB |
testcase_53 | AC | 123 ms
96,812 KB |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | AC | 167 ms
106,796 KB |
testcase_58 | AC | 168 ms
106,848 KB |
testcase_59 | AC | 124 ms
96,564 KB |
testcase_60 | AC | 231 ms
127,152 KB |
testcase_61 | AC | 236 ms
127,104 KB |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | AC | 50 ms
63,872 KB |
testcase_67 | AC | 51 ms
64,384 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 | 83 ms
77,716 KB |
testcase_76 | WA | - |
testcase_77 | AC | 166 ms
105,736 KB |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | AC | 61 ms
73,824 KB |
testcase_83 | AC | 167 ms
105,728 KB |
testcase_84 | AC | 242 ms
129,920 KB |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
ソースコード
import sys INF = 1 << 60 MOD = 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()