結果
問題 | No.843 Triple Primes |
ユーザー |
![]() |
提出日時 | 2019-10-18 16:32:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 537 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 16,456 KB |
最終ジャッジ日時 | 2024-06-25 14:36:50 |
合計ジャッジ時間 | 34,060 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 WA * 4 |
ソースコード
N = int(input()) def eratosthenes(n): is_primes = [True] * n for x in range(2, int(n ** 0.5) + 1): if is_primes[x]: for mx in range(2 * x, n, x): is_primes[mx] = False return [i for i in range(2, n) if is_primes[i]] primes = eratosthenes(N) prime_set = set(primes) r_candidates = [int(n ** 0.5) for n in range(2, N + 1) if (n ** 0.5) in prime_set] ans = 0 for r in r_candidates: for p in primes: q = r ** 2 - p if q in prime_set: ans += 1 print(ans)