結果

問題 No.843 Triple Primes
ユーザー AT274_AT274_
提出日時 2019-10-18 16:44:23
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 503 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 86,592 KB
実行使用メモリ 87,840 KB
最終ジャッジ日時 2023-09-07 20:57:26
合計ジャッジ時間 8,963 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,528 KB
testcase_01 AC 260 ms
87,840 KB
testcase_02 AC 76 ms
76,432 KB
testcase_03 AC 78 ms
76,596 KB
testcase_04 AC 79 ms
76,300 KB
testcase_05 AC 78 ms
76,364 KB
testcase_06 AC 79 ms
76,496 KB
testcase_07 AC 179 ms
84,728 KB
testcase_08 AC 206 ms
86,032 KB
testcase_09 AC 260 ms
87,324 KB
testcase_10 AC 190 ms
84,956 KB
testcase_11 AC 225 ms
86,248 KB
testcase_12 AC 248 ms
87,508 KB
testcase_13 AC 234 ms
86,320 KB
testcase_14 AC 236 ms
86,392 KB
testcase_15 AC 187 ms
84,684 KB
testcase_16 AC 191 ms
85,264 KB
testcase_17 RE -
testcase_18 AC 74 ms
71,900 KB
testcase_19 AC 74 ms
71,740 KB
testcase_20 AC 97 ms
78,400 KB
testcase_21 AC 90 ms
77,012 KB
testcase_22 AC 127 ms
81,708 KB
testcase_23 AC 130 ms
82,436 KB
testcase_24 AC 98 ms
78,352 KB
testcase_25 AC 103 ms
77,672 KB
testcase_26 AC 258 ms
87,460 KB
testcase_27 AC 81 ms
76,596 KB
testcase_28 AC 242 ms
86,560 KB
testcase_29 AC 100 ms
78,644 KB
testcase_30 AC 253 ms
87,348 KB
testcase_31 AC 85 ms
76,840 KB
testcase_32 AC 84 ms
76,684 KB
testcase_33 AC 100 ms
78,940 KB
testcase_34 AC 119 ms
81,212 KB
testcase_35 AC 263 ms
87,620 KB
testcase_36 AC 98 ms
77,408 KB
testcase_37 AC 172 ms
84,740 KB
testcase_38 AC 139 ms
82,752 KB
testcase_39 AC 242 ms
86,968 KB
testcase_40 AC 72 ms
71,504 KB
testcase_41 RE -
testcase_42 AC 196 ms
85,948 KB
testcase_43 AC 222 ms
86,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())


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

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


primes = eratosthenes(N)
prime_set = set(primes)

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

print(ans)
0