結果

問題 No.843 Triple Primes
ユーザー MineMine
提出日時 2020-09-15 22:21:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 79,560 KB
最終ジャッジ日時 2023-09-04 02:59:40
合計ジャッジ時間 14,188 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,472 KB
testcase_01 AC 503 ms
79,188 KB
testcase_02 AC 93 ms
76,624 KB
testcase_03 AC 94 ms
76,836 KB
testcase_04 AC 96 ms
76,692 KB
testcase_05 AC 93 ms
76,640 KB
testcase_06 AC 94 ms
76,716 KB
testcase_07 AC 387 ms
78,384 KB
testcase_08 AC 426 ms
78,472 KB
testcase_09 AC 489 ms
79,304 KB
testcase_10 AC 404 ms
78,520 KB
testcase_11 AC 451 ms
79,096 KB
testcase_12 AC 480 ms
79,272 KB
testcase_13 AC 464 ms
79,156 KB
testcase_14 AC 465 ms
79,024 KB
testcase_15 AC 399 ms
78,572 KB
testcase_16 AC 402 ms
78,420 KB
testcase_17 AC 79 ms
71,248 KB
testcase_18 AC 78 ms
71,376 KB
testcase_19 AC 79 ms
71,232 KB
testcase_20 AC 160 ms
77,324 KB
testcase_21 AC 125 ms
77,220 KB
testcase_22 AC 269 ms
78,024 KB
testcase_23 AC 282 ms
78,244 KB
testcase_24 AC 166 ms
77,448 KB
testcase_25 AC 143 ms
77,332 KB
testcase_26 AC 488 ms
79,340 KB
testcase_27 AC 97 ms
76,732 KB
testcase_28 AC 466 ms
79,168 KB
testcase_29 AC 172 ms
77,216 KB
testcase_30 AC 482 ms
79,380 KB
testcase_31 AC 110 ms
77,316 KB
testcase_32 AC 101 ms
76,420 KB
testcase_33 AC 185 ms
77,404 KB
testcase_34 AC 250 ms
77,824 KB
testcase_35 AC 495 ms
79,560 KB
testcase_36 AC 138 ms
77,376 KB
testcase_37 AC 379 ms
78,128 KB
testcase_38 AC 319 ms
77,872 KB
testcase_39 AC 479 ms
78,996 KB
testcase_40 AC 81 ms
71,364 KB
testcase_41 AC 79 ms
71,108 KB
testcase_42 AC 413 ms
78,828 KB
testcase_43 AC 448 ms
78,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

prime = []
for i in range(1, n+1):
    if is_prime(i):
        prime.append(i)

if n == 1:
    print(0)
else:
    ans = 1
    for r in prime[1:]:
        if r**2-2 > n:
            break
        if r**2-2 in prime:
            ans += 2
    print(ans)
0