結果

問題 No.732 3PrimeCounting
コンテスト
ユーザー PNJ
提出日時 2023-07-07 23:18:43
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 520 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 255 ms
コンパイル使用メモリ 96,244 KB
実行使用メモリ 142,720 KB
最終ジャッジ日時 2026-08-22 09:13:35
合計ジャッジ時間 59,993 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 82 TLE * 6 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict

def eratosthenes(N):
    P = []
    d = defaultdict(int)
    for p in range(2,N+1):
        if d[p] == 1:
            continue
        P.append(p)
        for q in range(1,N//p+1):
            d[p*q] = 1
    return P

d = defaultdict(int)
N = int(input())
P = eratosthenes(300000)
Q = [2]
S = []
ans = 0
for i in range(2,len(P)):
  c = P[i]
  if c > N:
    break
  for p in Q:
    q = p + P[i-1]
    d[q] += 1
  Q.append(P[i-1])
  for p in P:
    q = p - c
    ans += d[q]
print(ans)
0