結果

問題 No.843 Triple Primes
ユーザー AT274_AT274_
提出日時 2019-10-18 16:32:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 94,612 KB
最終ジャッジ日時 2023-09-07 20:54:10
合計ジャッジ時間 13,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,516 KB
testcase_01 AC 422 ms
94,280 KB
testcase_02 AC 83 ms
76,752 KB
testcase_03 AC 82 ms
76,672 KB
testcase_04 AC 95 ms
76,704 KB
testcase_05 AC 82 ms
76,788 KB
testcase_06 AC 85 ms
76,672 KB
testcase_07 AC 304 ms
90,504 KB
testcase_08 AC 341 ms
92,244 KB
testcase_09 AC 414 ms
94,376 KB
testcase_10 AC 317 ms
90,580 KB
testcase_11 AC 364 ms
92,320 KB
testcase_12 AC 407 ms
94,612 KB
testcase_13 AC 378 ms
92,548 KB
testcase_14 AC 377 ms
92,520 KB
testcase_15 AC 308 ms
90,572 KB
testcase_16 AC 321 ms
90,600 KB
testcase_17 AC 72 ms
71,492 KB
testcase_18 WA -
testcase_19 AC 74 ms
71,540 KB
testcase_20 AC 135 ms
80,160 KB
testcase_21 AC 108 ms
77,132 KB
testcase_22 AC 208 ms
85,308 KB
testcase_23 AC 216 ms
86,412 KB
testcase_24 AC 139 ms
80,496 KB
testcase_25 AC 137 ms
79,020 KB
testcase_26 AC 415 ms
94,312 KB
testcase_27 AC 91 ms
76,912 KB
testcase_28 AC 428 ms
92,616 KB
testcase_29 AC 141 ms
80,776 KB
testcase_30 AC 402 ms
94,288 KB
testcase_31 AC 95 ms
77,324 KB
testcase_32 AC 91 ms
76,964 KB
testcase_33 AC 146 ms
81,024 KB
testcase_34 AC 192 ms
85,212 KB
testcase_35 AC 414 ms
94,204 KB
testcase_36 AC 125 ms
78,748 KB
testcase_37 AC 289 ms
90,320 KB
testcase_38 AC 238 ms
86,956 KB
testcase_39 AC 405 ms
93,964 KB
testcase_40 WA -
testcase_41 AC 73 ms
71,484 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