結果

問題 No.843 Triple Primes
ユーザー mkawa2mkawa2
提出日時 2019-07-03 21:01:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 960 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 12,340 KB
最終ジャッジ日時 2023-10-14 12:55:35
合計ジャッジ時間 23,456 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,852 KB
testcase_01 AC 953 ms
12,232 KB
testcase_02 AC 18 ms
7,820 KB
testcase_03 AC 17 ms
7,816 KB
testcase_04 AC 20 ms
7,872 KB
testcase_05 AC 17 ms
7,864 KB
testcase_06 AC 21 ms
7,776 KB
testcase_07 AC 727 ms
12,012 KB
testcase_08 AC 803 ms
12,124 KB
testcase_09 AC 960 ms
12,340 KB
testcase_10 AC 774 ms
12,032 KB
testcase_11 AC 855 ms
12,224 KB
testcase_12 AC 921 ms
12,156 KB
testcase_13 AC 882 ms
12,160 KB
testcase_14 AC 886 ms
12,152 KB
testcase_15 AC 728 ms
11,968 KB
testcase_16 AC 747 ms
12,052 KB
testcase_17 AC 15 ms
8,136 KB
testcase_18 AC 14 ms
8,172 KB
testcase_19 AC 14 ms
7,832 KB
testcase_20 AC 185 ms
9,228 KB
testcase_21 AC 94 ms
8,968 KB
testcase_22 AC 447 ms
11,564 KB
testcase_23 AC 477 ms
11,584 KB
testcase_24 AC 201 ms
9,300 KB
testcase_25 AC 146 ms
9,140 KB
testcase_26 AC 943 ms
12,232 KB
testcase_27 AC 38 ms
8,280 KB
testcase_28 AC 898 ms
12,136 KB
testcase_29 AC 213 ms
9,208 KB
testcase_30 AC 926 ms
12,216 KB
testcase_31 AC 58 ms
8,460 KB
testcase_32 AC 34 ms
8,316 KB
testcase_33 AC 239 ms
9,340 KB
testcase_34 AC 414 ms
11,488 KB
testcase_35 AC 945 ms
12,292 KB
testcase_36 AC 129 ms
9,096 KB
testcase_37 AC 686 ms
11,924 KB
testcase_38 AC 553 ms
11,764 KB
testcase_39 AC 915 ms
12,216 KB
testcase_40 AC 15 ms
8,116 KB
testcase_41 AC 14 ms
8,176 KB
testcase_42 AC 787 ms
11,940 KB
testcase_43 AC 860 ms
12,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
if n==1:
    print(0)
    exit()
elif n==2:
    print(1)
    exit()
ele=[]
for i in range(3,n+1,2):
    for e in ele:
        if i%e==0:
            break
        if e**2>i:
            ele.append(i)
            break
    else:
        ele.append(i)
sel=set(ele)
cnt=0
for r in ele:
    p=r**2-2
    if p in sel:
        cnt+=1
    if p>n:
        break
print(cnt*2+1)
0