結果

問題 No.843 Triple Primes
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-07-07 22:01:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 85,016 KB
最終ジャッジ日時 2023-10-19 18:01:25
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,540 KB
testcase_01 AC 92 ms
85,016 KB
testcase_02 AC 44 ms
59,736 KB
testcase_03 AC 46 ms
59,736 KB
testcase_04 AC 51 ms
62,432 KB
testcase_05 AC 45 ms
59,736 KB
testcase_06 AC 49 ms
62,432 KB
testcase_07 AC 83 ms
83,668 KB
testcase_08 AC 87 ms
84,196 KB
testcase_09 AC 96 ms
84,792 KB
testcase_10 AC 84 ms
83,668 KB
testcase_11 AC 88 ms
84,196 KB
testcase_12 AC 93 ms
84,528 KB
testcase_13 AC 93 ms
84,460 KB
testcase_14 AC 89 ms
84,460 KB
testcase_15 AC 84 ms
83,932 KB
testcase_16 AC 86 ms
83,668 KB
testcase_17 AC 39 ms
53,564 KB
testcase_18 AC 38 ms
53,564 KB
testcase_19 AC 38 ms
53,564 KB
testcase_20 AC 59 ms
73,584 KB
testcase_21 AC 55 ms
67,676 KB
testcase_22 AC 78 ms
82,484 KB
testcase_23 AC 79 ms
82,484 KB
testcase_24 AC 60 ms
73,712 KB
testcase_25 AC 57 ms
70,720 KB
testcase_26 AC 94 ms
84,792 KB
testcase_27 AC 51 ms
64,924 KB
testcase_28 AC 89 ms
84,460 KB
testcase_29 AC 59 ms
74,092 KB
testcase_30 AC 91 ms
84,792 KB
testcase_31 AC 51 ms
65,180 KB
testcase_32 AC 50 ms
64,868 KB
testcase_33 AC 59 ms
74,364 KB
testcase_34 AC 75 ms
82,344 KB
testcase_35 AC 93 ms
84,792 KB
testcase_36 AC 55 ms
70,368 KB
testcase_37 AC 84 ms
83,404 KB
testcase_38 AC 80 ms
82,748 KB
testcase_39 AC 90 ms
84,528 KB
testcase_40 AC 37 ms
53,564 KB
testcase_41 AC 38 ms
53,564 KB
testcase_42 AC 86 ms
83,932 KB
testcase_43 AC 89 ms
84,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0