結果

問題 No.843 Triple Primes
ユーザー kozykozy
提出日時 2020-07-22 16:40:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 491 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 10,572 KB
実行使用メモリ 29,756 KB
最終ジャッジ日時 2023-09-02 22:08:13
合計ジャッジ時間 16,662 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 704 ms
29,744 KB
testcase_02 AC 19 ms
8,628 KB
testcase_03 AC 19 ms
8,300 KB
testcase_04 AC 22 ms
8,800 KB
testcase_05 AC 19 ms
8,336 KB
testcase_06 AC 22 ms
8,824 KB
testcase_07 AC 489 ms
25,616 KB
testcase_08 AC 542 ms
27,376 KB
testcase_09 AC 674 ms
29,756 KB
testcase_10 AC 537 ms
26,176 KB
testcase_11 AC 633 ms
28,292 KB
testcase_12 AC 713 ms
29,452 KB
testcase_13 AC 665 ms
28,784 KB
testcase_14 AC 639 ms
28,820 KB
testcase_15 AC 516 ms
25,736 KB
testcase_16 AC 521 ms
26,096 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 17 ms
7,788 KB
testcase_20 AC 120 ms
14,284 KB
testcase_21 AC 65 ms
11,636 KB
testcase_22 AC 294 ms
20,292 KB
testcase_23 AC 305 ms
20,672 KB
testcase_24 AC 126 ms
14,428 KB
testcase_25 AC 95 ms
12,980 KB
testcase_26 AC 704 ms
29,576 KB
testcase_27 AC 32 ms
9,480 KB
testcase_28 AC 663 ms
28,948 KB
testcase_29 AC 138 ms
14,864 KB
testcase_30 AC 630 ms
29,436 KB
testcase_31 AC 43 ms
10,200 KB
testcase_32 AC 30 ms
9,480 KB
testcase_33 AC 156 ms
15,512 KB
testcase_34 AC 257 ms
19,420 KB
testcase_35 AC 725 ms
29,732 KB
testcase_36 AC 85 ms
12,508 KB
testcase_37 AC 445 ms
24,996 KB
testcase_38 AC 357 ms
22,328 KB
testcase_39 AC 615 ms
29,172 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 509 ms
26,640 KB
testcase_43 AC 660 ms
28,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sieve_of_eratosthenes(n):
    candidate = list(range(2, n+1))
    prime = []
    limit = n**0.5 + 1
    while True:
        p = candidate[0] 
        if limit <= p:
            prime.extend(candidate)
            break
        prime.append(p)
        candidate = [i for i in candidate if i % p != 0]
    return prime
N=int(input())
prime = sieve_of_eratosthenes(N)
s=0
prime2=[i for i in prime if i<=800]
for i in range(len(prime2)):
  if (prime2[i]**2)-2 in prime:
    s+=1
print(s*2-1)
0