結果

問題 No.732 3PrimeCounting
ユーザー PNJPNJ
提出日時 2023-11-21 05:29:30
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 597 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 112,648 KB
最終ジャッジ日時 2023-11-21 05:30:18
合計ジャッジ時間 45,493 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
69,480 KB
testcase_01 AC 58 ms
69,480 KB
testcase_02 AC 58 ms
69,480 KB
testcase_03 AC 58 ms
69,480 KB
testcase_04 AC 62 ms
69,480 KB
testcase_05 AC 58 ms
69,480 KB
testcase_06 AC 58 ms
69,480 KB
testcase_07 AC 58 ms
69,480 KB
testcase_08 AC 58 ms
69,480 KB
testcase_09 AC 66 ms
69,480 KB
testcase_10 AC 58 ms
69,480 KB
testcase_11 AC 58 ms
69,480 KB
testcase_12 AC 58 ms
69,480 KB
testcase_13 AC 58 ms
69,480 KB
testcase_14 AC 58 ms
69,480 KB
testcase_15 AC 58 ms
69,480 KB
testcase_16 AC 59 ms
69,480 KB
testcase_17 AC 58 ms
69,480 KB
testcase_18 AC 58 ms
69,480 KB
testcase_19 AC 58 ms
69,480 KB
testcase_20 AC 65 ms
72,000 KB
testcase_21 AC 72 ms
74,184 KB
testcase_22 AC 72 ms
74,184 KB
testcase_23 AC 60 ms
69,864 KB
testcase_24 AC 60 ms
69,864 KB
testcase_25 AC 91 ms
76,388 KB
testcase_26 AC 75 ms
76,260 KB
testcase_27 AC 65 ms
72,000 KB
testcase_28 AC 65 ms
72,000 KB
testcase_29 AC 70 ms
74,184 KB
testcase_30 AC 70 ms
74,184 KB
testcase_31 AC 73 ms
76,260 KB
testcase_32 AC 77 ms
76,260 KB
testcase_33 AC 78 ms
76,260 KB
testcase_34 AC 77 ms
76,260 KB
testcase_35 AC 74 ms
76,260 KB
testcase_36 AC 75 ms
76,260 KB
testcase_37 AC 65 ms
72,000 KB
testcase_38 AC 64 ms
72,000 KB
testcase_39 AC 93 ms
76,260 KB
testcase_40 AC 74 ms
76,260 KB
testcase_41 AC 74 ms
76,260 KB
testcase_42 AC 74 ms
76,260 KB
testcase_43 AC 71 ms
74,184 KB
testcase_44 AC 72 ms
74,184 KB
testcase_45 AC 67 ms
72,000 KB
testcase_46 AC 67 ms
72,000 KB
testcase_47 AC 68 ms
74,056 KB
testcase_48 AC 82 ms
76,900 KB
testcase_49 AC 82 ms
76,900 KB
testcase_50 AC 73 ms
74,184 KB
testcase_51 AC 72 ms
74,184 KB
testcase_52 AC 66 ms
72,000 KB
testcase_53 AC 135 ms
79,588 KB
testcase_54 AC 1,233 ms
88,840 KB
testcase_55 AC 1,238 ms
88,840 KB
testcase_56 AC 1,251 ms
88,840 KB
testcase_57 AC 251 ms
79,588 KB
testcase_58 AC 255 ms
79,588 KB
testcase_59 AC 133 ms
79,588 KB
testcase_60 AC 362 ms
79,588 KB
testcase_61 AC 385 ms
79,588 KB
testcase_62 AC 1,633 ms
91,912 KB
testcase_63 AC 693 ms
82,184 KB
testcase_64 AC 453 ms
80,008 KB
testcase_65 AC 454 ms
80,008 KB
testcase_66 AC 58 ms
69,480 KB
testcase_67 AC 58 ms
69,480 KB
testcase_68 AC 1,406 ms
90,376 KB
testcase_69 AC 1,412 ms
90,376 KB
testcase_70 AC 1,247 ms
88,840 KB
testcase_71 AC 1,248 ms
88,840 KB
testcase_72 AC 633 ms
82,184 KB
testcase_73 AC 2,632 ms
102,664 KB
testcase_74 AC 2,647 ms
102,664 KB
testcase_75 AC 97 ms
76,260 KB
testcase_76 AC 1,367 ms
89,224 KB
testcase_77 AC 267 ms
79,588 KB
testcase_78 AC 2,077 ms
95,880 KB
testcase_79 AC 1,453 ms
91,400 KB
testcase_80 AC 1,805 ms
94,728 KB
testcase_81 AC 1,273 ms
88,840 KB
testcase_82 AC 65 ms
72,000 KB
testcase_83 AC 258 ms
79,588 KB
testcase_84 AC 286 ms
79,588 KB
testcase_85 AC 1,075 ms
86,536 KB
testcase_86 AC 1,849 ms
94,728 KB
testcase_87 TLE -
testcase_88 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
def Eratosthenes(N):
  is_prime = [1 for i in range(N+1)]
  is_prime[0] = is_prime[1] = 0
  P = []
  for p in range(2,N+1):
    if is_prime[p] == 0:
      continue
    P.append(p)
    for d in range(2,N//p+1):
      q = p*d
      is_prime[q] = 0
  return P

N = int(input())
P = Eratosthenes(300000)
P = P[::-1]
d = defaultdict(int)
Q = []
ans = 0
m = 0
while len(P):
  c = P.pop()
  if c > N:
    break
  for p in reversed(P):
    if p - c > m:
      break
    ans += d[p-c]
  for p in Q:
    d[p+c] += 1
  if c >= 3:
    m = Q[-1] + c
  Q.append(c)
print(ans)
0