結果

問題 No.843 Triple Primes
ユーザー DrDrpilotDrDrpilot
提出日時 2022-02-12 12:27:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 13,904 KB
最終ジャッジ日時 2023-09-10 23:30:50
合計ジャッジ時間 4,378 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 96 ms
13,848 KB
testcase_02 AC 17 ms
7,748 KB
testcase_03 AC 17 ms
7,800 KB
testcase_04 AC 17 ms
8,460 KB
testcase_05 AC 17 ms
7,840 KB
testcase_06 AC 17 ms
8,500 KB
testcase_07 AC 77 ms
12,896 KB
testcase_08 AC 88 ms
13,244 KB
testcase_09 AC 98 ms
13,864 KB
testcase_10 AC 82 ms
13,040 KB
testcase_11 AC 87 ms
13,504 KB
testcase_12 AC 94 ms
13,744 KB
testcase_13 AC 91 ms
13,612 KB
testcase_14 AC 90 ms
13,672 KB
testcase_15 AC 81 ms
12,900 KB
testcase_16 AC 82 ms
12,940 KB
testcase_17 AC 16 ms
7,848 KB
testcase_18 AC 16 ms
7,840 KB
testcase_19 AC 16 ms
7,800 KB
testcase_20 AC 37 ms
9,728 KB
testcase_21 AC 28 ms
9,204 KB
testcase_22 AC 61 ms
12,036 KB
testcase_23 AC 63 ms
11,840 KB
testcase_24 AC 37 ms
9,772 KB
testcase_25 AC 33 ms
9,656 KB
testcase_26 AC 95 ms
13,904 KB
testcase_27 AC 21 ms
8,448 KB
testcase_28 AC 92 ms
13,644 KB
testcase_29 AC 39 ms
9,976 KB
testcase_30 AC 94 ms
13,864 KB
testcase_31 AC 22 ms
8,688 KB
testcase_32 AC 20 ms
8,480 KB
testcase_33 AC 42 ms
10,276 KB
testcase_34 AC 57 ms
11,860 KB
testcase_35 AC 96 ms
13,832 KB
testcase_36 AC 31 ms
9,412 KB
testcase_37 AC 78 ms
12,796 KB
testcase_38 AC 69 ms
12,056 KB
testcase_39 AC 92 ms
13,680 KB
testcase_40 AC 16 ms
7,848 KB
testcase_41 AC 16 ms
7,748 KB
testcase_42 AC 83 ms
13,008 KB
testcase_43 AC 89 ms
13,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(n):
    is_prime=[True] * (n+1)
    is_prime[0]=False
    is_prime[1]=False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]
n=int(input())
l=Eratosthenes(n)
ans=0
l=set(l)
for i in l:
    if i*i-2 in l:
        ans+=1
ans*=2
if n>=2:
    ans-=1
print(ans)
0