結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2019-07-07 22:01:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 2,000 ms |
| コード長 | 479 bytes |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 85,504 KB |
| 最終ジャッジ日時 | 2024-09-19 14:20:10 |
| 合計ジャッジ時間 | 4,599 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 42 |
ソースコード
import math
n = int(input())
sieve = list(range(n + 1))
sieve[0] = sieve[1] = None
for x in range(2, math.ceil(math.sqrt(n)) + 1):
if sieve[x] is not None:
for y in range(x + x, n + 1, x):
sieve[y] = None
count = 0
primes = set(x for x in sieve if x is not None)
for q in primes:
x = q + 2
r = math.ceil(math.sqrt(x))
if r * r == x and r in primes:
if q == 2:
count += 1
else:
count += 2
print(count)
neko_the_shadow