結果

問題 No.843 Triple Primes
ユーザー mkawa2mkawa2
提出日時 2019-07-03 21:02:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 81,728 KB
実行使用メモリ 75,268 KB
最終ジャッジ日時 2023-10-19 17:57:48
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,256 KB
testcase_01 AC 148 ms
75,236 KB
testcase_02 AC 44 ms
59,828 KB
testcase_03 AC 45 ms
59,828 KB
testcase_04 AC 44 ms
59,828 KB
testcase_05 AC 45 ms
59,828 KB
testcase_06 AC 46 ms
59,828 KB
testcase_07 AC 122 ms
73,316 KB
testcase_08 AC 131 ms
74,220 KB
testcase_09 AC 147 ms
75,268 KB
testcase_10 AC 127 ms
73,344 KB
testcase_11 AC 136 ms
74,256 KB
testcase_12 AC 144 ms
75,252 KB
testcase_13 AC 140 ms
74,284 KB
testcase_14 AC 141 ms
74,284 KB
testcase_15 AC 124 ms
73,328 KB
testcase_16 AC 126 ms
73,340 KB
testcase_17 AC 37 ms
53,352 KB
testcase_18 AC 37 ms
53,352 KB
testcase_19 AC 38 ms
53,352 KB
testcase_20 AC 63 ms
64,776 KB
testcase_21 AC 53 ms
61,876 KB
testcase_22 AC 92 ms
69,048 KB
testcase_23 AC 95 ms
69,656 KB
testcase_24 AC 65 ms
64,784 KB
testcase_25 AC 59 ms
64,376 KB
testcase_26 AC 146 ms
75,268 KB
testcase_27 AC 48 ms
61,876 KB
testcase_28 AC 141 ms
74,292 KB
testcase_29 AC 67 ms
65,012 KB
testcase_30 AC 144 ms
75,252 KB
testcase_31 AC 50 ms
61,876 KB
testcase_32 AC 47 ms
61,876 KB
testcase_33 AC 70 ms
65,036 KB
testcase_34 AC 88 ms
69,008 KB
testcase_35 AC 146 ms
75,268 KB
testcase_36 AC 59 ms
64,208 KB
testcase_37 AC 120 ms
73,288 KB
testcase_38 AC 104 ms
69,724 KB
testcase_39 AC 142 ms
74,924 KB
testcase_40 AC 38 ms
53,352 KB
testcase_41 AC 38 ms
53,352 KB
testcase_42 AC 129 ms
74,200 KB
testcase_43 AC 137 ms
74,256 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