結果

問題 No.843 Triple Primes
ユーザー rlangevinrlangevin
提出日時 2023-01-03 10:46:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 86,524 KB
実行使用メモリ 85,080 KB
最終ジャッジ日時 2023-08-18 00:14:30
合計ジャッジ時間 7,347 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,796 KB
testcase_01 AC 105 ms
84,748 KB
testcase_02 AC 82 ms
75,360 KB
testcase_03 AC 78 ms
75,232 KB
testcase_04 AC 81 ms
75,896 KB
testcase_05 AC 78 ms
75,068 KB
testcase_06 AC 80 ms
75,884 KB
testcase_07 AC 99 ms
82,824 KB
testcase_08 AC 101 ms
83,632 KB
testcase_09 AC 105 ms
84,600 KB
testcase_10 AC 101 ms
83,032 KB
testcase_11 AC 101 ms
83,796 KB
testcase_12 AC 103 ms
84,700 KB
testcase_13 AC 103 ms
84,008 KB
testcase_14 AC 105 ms
83,960 KB
testcase_15 AC 99 ms
82,616 KB
testcase_16 AC 99 ms
82,860 KB
testcase_17 WA -
testcase_18 AC 74 ms
71,340 KB
testcase_19 AC 75 ms
71,080 KB
testcase_20 AC 87 ms
77,788 KB
testcase_21 AC 82 ms
76,464 KB
testcase_22 AC 93 ms
80,488 KB
testcase_23 AC 94 ms
80,932 KB
testcase_24 AC 88 ms
77,788 KB
testcase_25 AC 85 ms
77,028 KB
testcase_26 AC 103 ms
84,908 KB
testcase_27 AC 81 ms
76,120 KB
testcase_28 AC 103 ms
84,152 KB
testcase_29 AC 87 ms
78,152 KB
testcase_30 AC 101 ms
84,908 KB
testcase_31 AC 81 ms
76,220 KB
testcase_32 AC 83 ms
75,956 KB
testcase_33 AC 89 ms
78,064 KB
testcase_34 AC 93 ms
80,260 KB
testcase_35 AC 106 ms
85,080 KB
testcase_36 AC 86 ms
76,796 KB
testcase_37 AC 99 ms
82,580 KB
testcase_38 AC 96 ms
81,284 KB
testcase_39 AC 104 ms
84,824 KB
testcase_40 AC 76 ms
71,136 KB
testcase_41 WA -
testcase_42 AC 102 ms
83,592 KB
testcase_43 AC 103 ms
83,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import *

def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S


N = int(input())
S = set()
prime_set= Sieve(N)
i = 1
while i * i <= N + 2:
    if i in prime_set:
        S.add(i * i)
    i += 1
    

ans = 1
for v in prime_set:
    if v == 2:
        continue
    if v + 2 in S:
        ans += 2
print(ans)
0