結果
問題 |
No.732 3PrimeCounting
|
ユーザー |
![]() |
提出日時 | 2023-07-07 23:18:43 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 520 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 269,696 KB |
最終ジャッジ日時 | 2024-07-21 19:43:31 |
合計ジャッジ時間 | 20,982 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 54 TLE * 1 -- * 34 |
ソースコード
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)