結果

問題 No.843 Triple Primes
ユーザー AT274_AT274_
提出日時 2019-10-18 16:32:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 14,156 KB
最終ジャッジ日時 2023-09-07 20:55:44
合計ジャッジ時間 28,601 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 1,326 ms
14,120 KB
testcase_02 AC 21 ms
7,796 KB
testcase_03 AC 20 ms
7,872 KB
testcase_04 AC 25 ms
8,476 KB
testcase_05 AC 20 ms
7,908 KB
testcase_06 AC 27 ms
8,540 KB
testcase_07 AC 965 ms
12,860 KB
testcase_08 AC 1,109 ms
13,376 KB
testcase_09 AC 1,312 ms
13,972 KB
testcase_10 AC 1,085 ms
13,128 KB
testcase_11 AC 1,185 ms
13,552 KB
testcase_12 AC 1,261 ms
13,800 KB
testcase_13 AC 1,187 ms
13,636 KB
testcase_14 AC 1,289 ms
13,600 KB
testcase_15 AC 987 ms
12,952 KB
testcase_16 AC 1,063 ms
12,956 KB
testcase_17 AC 16 ms
7,892 KB
testcase_18 WA -
testcase_19 AC 16 ms
7,944 KB
testcase_20 AC 259 ms
9,828 KB
testcase_21 AC 125 ms
9,364 KB
testcase_22 AC 611 ms
12,072 KB
testcase_23 AC 656 ms
11,892 KB
testcase_24 AC 268 ms
9,828 KB
testcase_25 AC 192 ms
9,608 KB
testcase_26 AC 1,279 ms
14,156 KB
testcase_27 AC 51 ms
8,596 KB
testcase_28 AC 1,229 ms
13,576 KB
testcase_29 AC 293 ms
10,012 KB
testcase_30 AC 1,264 ms
13,780 KB
testcase_31 AC 78 ms
8,808 KB
testcase_32 AC 45 ms
8,532 KB
testcase_33 AC 329 ms
10,268 KB
testcase_34 AC 580 ms
11,948 KB
testcase_35 AC 1,283 ms
14,096 KB
testcase_36 AC 173 ms
9,284 KB
testcase_37 AC 934 ms
12,700 KB
testcase_38 AC 784 ms
12,216 KB
testcase_39 AC 1,256 ms
13,732 KB
testcase_40 WA -
testcase_41 AC 17 ms
7,888 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())


def eratosthenes(n):
    is_primes = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if is_primes[x]:
            for mx in range(2 * x, n, x):
                is_primes[mx] = False

    return [i for i in range(2, n) if is_primes[i]]


primes = eratosthenes(N)
prime_set = set(primes)
r_candidates = [int(n ** 0.5) for n in range(2, N + 1) if (n ** 0.5) in prime_set]

ans = 0
for r in r_candidates:
    for p in primes:
        q = r ** 2 - p
        if q in prime_set:
            ans += 1

print(ans)
0