結果
問題 | No.732 3PrimeCounting |
ユーザー | mkawa2 |
提出日時 | 2020-11-12 11:14:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,058 ms / 3,000 ms |
コード長 | 2,225 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 137,984 KB |
最終ジャッジ日時 | 2024-07-22 19:08:53 |
合計ジャッジ時間 | 21,568 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
67,072 KB |
testcase_01 | AC | 57 ms
67,072 KB |
testcase_02 | AC | 58 ms
67,584 KB |
testcase_03 | AC | 56 ms
67,328 KB |
testcase_04 | AC | 56 ms
67,328 KB |
testcase_05 | AC | 56 ms
67,200 KB |
testcase_06 | AC | 57 ms
67,456 KB |
testcase_07 | AC | 58 ms
67,328 KB |
testcase_08 | AC | 58 ms
67,712 KB |
testcase_09 | AC | 57 ms
67,840 KB |
testcase_10 | AC | 56 ms
67,712 KB |
testcase_11 | AC | 58 ms
67,584 KB |
testcase_12 | AC | 59 ms
67,968 KB |
testcase_13 | AC | 62 ms
67,968 KB |
testcase_14 | AC | 62 ms
68,224 KB |
testcase_15 | AC | 58 ms
68,096 KB |
testcase_16 | AC | 57 ms
68,096 KB |
testcase_17 | AC | 55 ms
67,840 KB |
testcase_18 | AC | 55 ms
68,736 KB |
testcase_19 | AC | 59 ms
68,480 KB |
testcase_20 | AC | 79 ms
90,112 KB |
testcase_21 | AC | 118 ms
135,424 KB |
testcase_22 | AC | 112 ms
135,296 KB |
testcase_23 | AC | 63 ms
75,648 KB |
testcase_24 | AC | 65 ms
75,904 KB |
testcase_25 | AC | 122 ms
130,944 KB |
testcase_26 | AC | 115 ms
135,552 KB |
testcase_27 | AC | 78 ms
98,816 KB |
testcase_28 | AC | 77 ms
99,200 KB |
testcase_29 | AC | 102 ms
127,488 KB |
testcase_30 | AC | 100 ms
127,488 KB |
testcase_31 | AC | 119 ms
135,424 KB |
testcase_32 | AC | 117 ms
134,784 KB |
testcase_33 | AC | 120 ms
135,296 KB |
testcase_34 | AC | 118 ms
135,040 KB |
testcase_35 | AC | 113 ms
135,168 KB |
testcase_36 | AC | 113 ms
135,552 KB |
testcase_37 | AC | 68 ms
83,200 KB |
testcase_38 | AC | 74 ms
83,328 KB |
testcase_39 | AC | 122 ms
135,808 KB |
testcase_40 | AC | 111 ms
135,680 KB |
testcase_41 | AC | 112 ms
135,552 KB |
testcase_42 | AC | 115 ms
135,808 KB |
testcase_43 | AC | 109 ms
135,424 KB |
testcase_44 | AC | 109 ms
135,424 KB |
testcase_45 | AC | 83 ms
104,960 KB |
testcase_46 | AC | 84 ms
104,960 KB |
testcase_47 | AC | 93 ms
115,200 KB |
testcase_48 | AC | 120 ms
130,560 KB |
testcase_49 | AC | 119 ms
130,560 KB |
testcase_50 | AC | 112 ms
135,936 KB |
testcase_51 | AC | 119 ms
135,296 KB |
testcase_52 | AC | 82 ms
102,272 KB |
testcase_53 | AC | 142 ms
136,832 KB |
testcase_54 | AC | 451 ms
134,272 KB |
testcase_55 | AC | 445 ms
137,344 KB |
testcase_56 | AC | 447 ms
136,832 KB |
testcase_57 | AC | 187 ms
136,704 KB |
testcase_58 | AC | 187 ms
136,704 KB |
testcase_59 | AC | 143 ms
136,576 KB |
testcase_60 | AC | 219 ms
136,576 KB |
testcase_61 | AC | 221 ms
136,960 KB |
testcase_62 | AC | 546 ms
137,472 KB |
testcase_63 | AC | 306 ms
136,832 KB |
testcase_64 | AC | 264 ms
136,576 KB |
testcase_65 | AC | 254 ms
136,960 KB |
testcase_66 | AC | 63 ms
74,240 KB |
testcase_67 | AC | 63 ms
74,496 KB |
testcase_68 | AC | 542 ms
137,344 KB |
testcase_69 | AC | 486 ms
137,216 KB |
testcase_70 | AC | 465 ms
137,148 KB |
testcase_71 | AC | 455 ms
136,704 KB |
testcase_72 | AC | 288 ms
134,016 KB |
testcase_73 | AC | 817 ms
137,600 KB |
testcase_74 | AC | 827 ms
134,784 KB |
testcase_75 | AC | 119 ms
131,328 KB |
testcase_76 | AC | 495 ms
137,344 KB |
testcase_77 | AC | 191 ms
136,576 KB |
testcase_78 | AC | 643 ms
137,600 KB |
testcase_79 | AC | 507 ms
137,472 KB |
testcase_80 | AC | 612 ms
137,216 KB |
testcase_81 | AC | 473 ms
137,216 KB |
testcase_82 | AC | 78 ms
95,360 KB |
testcase_83 | AC | 185 ms
136,448 KB |
testcase_84 | AC | 196 ms
136,704 KB |
testcase_85 | AC | 413 ms
136,960 KB |
testcase_86 | AC | 612 ms
137,472 KB |
testcase_87 | AC | 1,058 ms
137,984 KB |
testcase_88 | AC | 1,054 ms
137,472 KB |
ソースコード
from operator import itemgetter from itertools import * from bisect import * from collections import * from heapq import * import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def MI(): return map(int, sys.stdin.buffer.readline().split()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def MI1(): return map(int1, sys.stdin.buffer.readline().split()) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() def inval(ni, nj, h, w): if ni < 0 or ni >= h or nj < 0 or nj >= w: return True return False dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] inf = 10**16 class Sieve: def __init__(self, n): self.plist = [2] # n以下の素数のリスト min_prime_factor = [2, 0]*(n//2+5) for x in range(3, n+1, 2): if min_prime_factor[x] == 0: min_prime_factor[x] = x self.plist.append(x) if x**2 > n: continue for y in range(x**2, n+5, 2*x): if min_prime_factor[y] == 0: min_prime_factor[y] = x self.min_prime_factor = min_prime_factor def isprime(self, x): return self.min_prime_factor[x] == x # これが素因数分解(prime factorization) def pfct(self, x): pp, ee = [], [] while x > 1: mpf = self.min_prime_factor[x] if pp and mpf == pp[-1]: ee[-1] += 1 else: pp.append(mpf) ee.append(1) x //= mpf return [(p, e) for p, e in zip(pp, ee)] n = II() sv = Sieve(300000) pp = sv.plist cnt = [0]*(2*n+1) ans = 0 for i, c in enumerate(pp[2:], 2): if c > n: break p1 = pp[i-1] for p2 in pp[:i-1]: cnt[p1+p2] += 1 for s in pp[i+1:]: if s-c < 4: continue if s-c > 2*n: break ans += cnt[s-c] print(ans)