結果

問題 No.843 Triple Primes
ユーザー ttrttr
提出日時 2020-02-05 22:37:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,792 KB
実行使用メモリ 15,660 KB
最終ジャッジ日時 2023-10-24 12:57:52
合計ジャッジ時間 8,878 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,028 KB
testcase_01 AC 234 ms
15,660 KB
testcase_02 AC 29 ms
10,100 KB
testcase_03 AC 29 ms
10,080 KB
testcase_04 AC 30 ms
10,144 KB
testcase_05 AC 29 ms
10,084 KB
testcase_06 AC 31 ms
10,152 KB
testcase_07 AC 195 ms
14,588 KB
testcase_08 AC 212 ms
14,992 KB
testcase_09 AC 251 ms
15,628 KB
testcase_10 AC 204 ms
14,756 KB
testcase_11 AC 243 ms
15,212 KB
testcase_12 AC 238 ms
15,508 KB
testcase_13 AC 232 ms
15,360 KB
testcase_14 AC 229 ms
15,368 KB
testcase_15 AC 215 ms
14,660 KB
testcase_16 AC 205 ms
14,724 KB
testcase_17 AC 29 ms
10,028 KB
testcase_18 AC 27 ms
10,028 KB
testcase_19 AC 27 ms
10,028 KB
testcase_20 AC 82 ms
11,432 KB
testcase_21 AC 59 ms
10,668 KB
testcase_22 AC 138 ms
13,064 KB
testcase_23 AC 142 ms
13,352 KB
testcase_24 AC 86 ms
11,492 KB
testcase_25 AC 70 ms
11,224 KB
testcase_26 AC 236 ms
15,612 KB
testcase_27 AC 39 ms
10,148 KB
testcase_28 AC 227 ms
15,412 KB
testcase_29 AC 91 ms
11,568 KB
testcase_30 AC 239 ms
15,536 KB
testcase_31 AC 45 ms
10,404 KB
testcase_32 AC 37 ms
10,140 KB
testcase_33 AC 99 ms
11,692 KB
testcase_34 AC 133 ms
12,624 KB
testcase_35 AC 259 ms
15,628 KB
testcase_36 AC 67 ms
10,932 KB
testcase_37 AC 197 ms
14,420 KB
testcase_38 AC 163 ms
13,752 KB
testcase_39 AC 235 ms
15,460 KB
testcase_40 AC 28 ms
10,028 KB
testcase_41 AC 28 ms
10,028 KB
testcase_42 AC 214 ms
14,860 KB
testcase_43 AC 218 ms
15,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

prime = [-1]*(N+1)
L = []
for i in range(2, N+1):
    if prime[i] == 0:
        continue
    L.append(i)
    prime[i] = 1
    for j in range(2*i, N+1, i):
        prime[j] = 0

ans = -1
for r in L:
    if r**2-2 > N:
        break
    if prime[r**2-2] == 1:
        ans += 2

print(max(0, ans))
0