結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-12 18:11:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 454 bytes |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 82,420 KB |
| 実行使用メモリ | 78,512 KB |
| 最終ジャッジ日時 | 2024-12-20 09:12:12 |
| 合計ジャッジ時間 | 4,254 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 WA * 2 |
ソースコード
def primes(N):
#N = 5 * (10 ** 5)
res = []
isprime = [True] * (N + 1)
isprime[0] = isprime[1] = False
for i in range(2, N + 1):
if isprime[i]:
res.append(i)
for j in range(i * 2, N + 1, i):
isprime[j] = False
return res
N = int(input())
P = primes(N)
#print(len(P))
S = set([r * r for r in P])
ans = 0
for q in P:
q2 = q + 2
if q2 in S:
ans += 1
print(ans * 2 - 1)