結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
AT274_
|
| 提出日時 | 2019-10-18 16:44:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 503 bytes |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 74,112 KB |
| 最終ジャッジ日時 | 2024-06-25 14:38:36 |
| 合計ジャッジ時間 | 7,239 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 RE * 2 |
ソースコード
N = int(input())
def eratosthenes(n):
is_primes = [True] * (n + 1)
for x in range(2, int(n ** 0.5 + 1) + 1):
if is_primes[x]:
for mx in range(2 * x, n + 1, x):
is_primes[mx] = False
return [i for i in range(2, n + 1) if is_primes[i]]
primes = eratosthenes(N)
prime_set = set(primes)
ans = 0
for r in primes:
if r ** 2 > 2 * N:
break
for p in primes:
q = r ** 2 - p
if q in prime_set:
ans += 1
print(ans)
AT274_