結果

問題 No.843 Triple Primes
ユーザー NagisaNagisa
提出日時 2019-06-28 22:06:16
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 77,796 KB
最終ジャッジ日時 2023-10-19 17:44:23
合計ジャッジ時間 12,157 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,732 KB
testcase_01 AC 472 ms
77,796 KB
testcase_02 AC 50 ms
62,640 KB
testcase_03 AC 51 ms
62,640 KB
testcase_04 AC 53 ms
62,652 KB
testcase_05 AC 51 ms
62,640 KB
testcase_06 AC 53 ms
62,652 KB
testcase_07 AC 363 ms
77,076 KB
testcase_08 AC 403 ms
77,404 KB
testcase_09 AC 470 ms
77,796 KB
testcase_10 AC 381 ms
77,092 KB
testcase_11 AC 427 ms
77,424 KB
testcase_12 AC 457 ms
77,456 KB
testcase_13 AC 443 ms
77,440 KB
testcase_14 AC 444 ms
77,440 KB
testcase_15 AC 370 ms
77,080 KB
testcase_16 AC 381 ms
77,088 KB
testcase_17 AC 41 ms
53,552 KB
testcase_18 AC 41 ms
53,668 KB
testcase_19 AC 41 ms
53,732 KB
testcase_20 AC 121 ms
70,844 KB
testcase_21 AC 81 ms
66,748 KB
testcase_22 AC 242 ms
76,528 KB
testcase_23 AC 251 ms
76,540 KB
testcase_24 AC 127 ms
70,844 KB
testcase_25 AC 104 ms
68,796 KB
testcase_26 AC 469 ms
77,792 KB
testcase_27 AC 59 ms
64,700 KB
testcase_28 AC 446 ms
77,448 KB
testcase_29 AC 133 ms
70,844 KB
testcase_30 AC 461 ms
77,464 KB
testcase_31 AC 67 ms
64,700 KB
testcase_32 AC 58 ms
64,700 KB
testcase_33 AC 145 ms
72,892 KB
testcase_34 AC 221 ms
76,588 KB
testcase_35 AC 470 ms
77,796 KB
testcase_36 AC 96 ms
68,796 KB
testcase_37 AC 348 ms
77,056 KB
testcase_38 AC 286 ms
76,540 KB
testcase_39 AC 451 ms
77,456 KB
testcase_40 AC 39 ms
53,668 KB
testcase_41 AC 39 ms
53,552 KB
testcase_42 AC 393 ms
77,104 KB
testcase_43 AC 426 ms
77,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N <= 1:
    print(0)
    exit(0)

import math
P = [2]
for k in range(3,N+1):
    f = 1
    for l in range(2,int(math.sqrt(k))+1):
        if k % l == 0:
            f = 0
            break
    if f==1:
        P.append(k)

P = sorted(P)
R = []
for e in P:
    if e*e <= N*2:
        R.append(e*e)
    else:
        break

l = len(P)
ans = 1
for k in range(1,l):
    if 2+P[k] in R:
        ans += 2
print(ans)
0