結果

問題 No.843 Triple Primes
ユーザー syunsukesyunsuke
提出日時 2019-08-29 17:53:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 598 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,400 KB
最終ジャッジ日時 2024-04-28 21:06:39
合計ジャッジ時間 14,877 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 598 ms
17,160 KB
testcase_02 AC 35 ms
10,880 KB
testcase_03 AC 33 ms
10,880 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 34 ms
10,752 KB
testcase_06 AC 40 ms
10,880 KB
testcase_07 AC 481 ms
16,368 KB
testcase_08 AC 525 ms
16,732 KB
testcase_09 AC 592 ms
17,144 KB
testcase_10 AC 495 ms
16,744 KB
testcase_11 AC 547 ms
16,844 KB
testcase_12 AC 573 ms
17,056 KB
testcase_13 AC 569 ms
16,948 KB
testcase_14 AC 564 ms
16,952 KB
testcase_15 AC 476 ms
16,424 KB
testcase_16 AC 494 ms
16,464 KB
testcase_17 AC 28 ms
10,752 KB
testcase_18 AC 30 ms
10,752 KB
testcase_19 AC 29 ms
10,880 KB
testcase_20 AC 166 ms
12,928 KB
testcase_21 AC 103 ms
11,904 KB
testcase_22 AC 320 ms
15,520 KB
testcase_23 AC 334 ms
15,480 KB
testcase_24 AC 173 ms
13,056 KB
testcase_25 AC 138 ms
12,288 KB
testcase_26 AC 593 ms
17,256 KB
testcase_27 AC 59 ms
11,136 KB
testcase_28 AC 585 ms
17,116 KB
testcase_29 AC 188 ms
13,184 KB
testcase_30 AC 575 ms
17,076 KB
testcase_31 AC 76 ms
11,648 KB
testcase_32 AC 55 ms
11,008 KB
testcase_33 AC 202 ms
13,312 KB
testcase_34 AC 299 ms
15,340 KB
testcase_35 AC 598 ms
17,400 KB
testcase_36 AC 124 ms
12,160 KB
testcase_37 AC 444 ms
16,372 KB
testcase_38 AC 379 ms
15,764 KB
testcase_39 AC 563 ms
17,276 KB
testcase_40 AC 30 ms
10,624 KB
testcase_41 AC 30 ms
10,624 KB
testcase_42 AC 505 ms
16,692 KB
testcase_43 AC 559 ms
16,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

n=[1 for i in range(N+1)]
n[0]=0
n[1]=0

for i in range(2,N):
    if n[i]==1:
        for j in range(2,N):
            if i*j>N:
                break
            else:
                n[i*j]=0
#print(n)
S=dict()
for i in range(3,N+1):
    if n[i]==1:
        S[i]=i
#print(S)

ans=1
for i in S.keys():
    if S[i]**2-2 in S:
        ans+=2
if N==1:
    print(0)
else:
    print(ans)
0