結果

問題 No.732 3PrimeCounting
コンテスト
ユーザー PNJ
提出日時 2023-07-07 23:18:43
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 520 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 85,420 KB
実行使用メモリ 154,852 KB
最終ジャッジ日時 2026-04-03 05:46:19
合計ジャッジ時間 39,070 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 68 TLE * 3 -- * 18
権限があれば一括ダウンロードができます

ソースコード

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