結果
問題 | No.843 Triple Primes |
ユーザー |
|
提出日時 | 2019-06-27 22:09:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 14,404 KB |
最終ジャッジ日時 | 2025-02-07 09:23:02 |
合計ジャッジ時間 | 4,306 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 42 |
ソースコード
N = int(input())def sieve(N):primes = [True] * (N + 1)primes[0] = Falseprimes[1] = Falsefor i in range(2, N + 1):if not primes[i]:continuefor j in range(i * i, N + 1, i):primes[j] = Falsereturn primesisPrimes = sieve(N)count = 0r = 2while r * r <= N + 2:k = r * r - 2if isPrimes[k] and isPrimes[r]:if k == r:count += 1else:count += 2r += 1print(count)