結果

問題 No.843 Triple Primes
ユーザー Akisawa0313Akisawa0313
提出日時 2021-04-28 11:37:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 292 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 10,692 KB
実行使用メモリ 13,876 KB
最終ジャッジ日時 2023-09-21 11:58:50
合計ジャッジ時間 7,595 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,800 KB
testcase_01 AC 221 ms
13,824 KB
testcase_02 AC 18 ms
7,784 KB
testcase_03 AC 17 ms
7,732 KB
testcase_04 AC 19 ms
8,376 KB
testcase_05 AC 17 ms
7,808 KB
testcase_06 AC 19 ms
8,348 KB
testcase_07 AC 188 ms
12,668 KB
testcase_08 AC 203 ms
13,156 KB
testcase_09 AC 236 ms
13,792 KB
testcase_10 AC 197 ms
12,840 KB
testcase_11 AC 207 ms
13,376 KB
testcase_12 AC 226 ms
13,764 KB
testcase_13 AC 218 ms
13,452 KB
testcase_14 AC 211 ms
13,444 KB
testcase_15 AC 184 ms
12,752 KB
testcase_16 AC 202 ms
12,976 KB
testcase_17 AC 16 ms
7,856 KB
testcase_18 AC 15 ms
7,828 KB
testcase_19 AC 15 ms
7,928 KB
testcase_20 AC 68 ms
9,660 KB
testcase_21 AC 43 ms
8,796 KB
testcase_22 AC 125 ms
11,116 KB
testcase_23 AC 135 ms
11,576 KB
testcase_24 AC 70 ms
9,576 KB
testcase_25 AC 58 ms
9,272 KB
testcase_26 AC 218 ms
13,740 KB
testcase_27 AC 26 ms
8,416 KB
testcase_28 AC 215 ms
13,500 KB
testcase_29 AC 76 ms
9,608 KB
testcase_30 AC 220 ms
13,792 KB
testcase_31 AC 34 ms
8,560 KB
testcase_32 AC 25 ms
8,232 KB
testcase_33 AC 82 ms
10,024 KB
testcase_34 AC 115 ms
11,060 KB
testcase_35 AC 233 ms
13,876 KB
testcase_36 AC 53 ms
9,172 KB
testcase_37 AC 180 ms
12,620 KB
testcase_38 AC 146 ms
12,004 KB
testcase_39 AC 213 ms
13,548 KB
testcase_40 AC 16 ms
7,792 KB
testcase_41 AC 16 ms
7,792 KB
testcase_42 AC 195 ms
12,892 KB
testcase_43 AC 205 ms
13,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

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

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

print(max(0, ans))
0