結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー neterukunneterukun
提出日時 2021-08-27 21:36:35
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 524 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-05-01 01:54:32
合計ジャッジ時間 12,661 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
57,600 KB
testcase_01 AC 46 ms
58,152 KB
testcase_02 AC 1,728 ms
76,416 KB
testcase_03 AC 43 ms
57,984 KB
testcase_04 AC 43 ms
57,728 KB
testcase_05 AC 42 ms
58,240 KB
testcase_06 AC 67 ms
67,328 KB
testcase_07 AC 61 ms
65,280 KB
testcase_08 AC 51 ms
61,184 KB
testcase_09 AC 52 ms
62,848 KB
testcase_10 AC 50 ms
61,312 KB
testcase_11 AC 96 ms
76,184 KB
testcase_12 AC 1,600 ms
76,468 KB
testcase_13 AC 645 ms
76,656 KB
testcase_14 AC 845 ms
76,276 KB
testcase_15 AC 1,074 ms
76,416 KB
testcase_16 AC 321 ms
76,336 KB
testcase_17 AC 133 ms
76,376 KB
testcase_18 AC 204 ms
76,612 KB
testcase_19 AC 1,646 ms
76,424 KB
testcase_20 AC 495 ms
76,168 KB
testcase_21 TLE -
testcase_22 AC 43 ms
57,792 KB
testcase_23 AC 285 ms
76,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_prime(x):
    if x == 2:
        return True
    if x == 1 or x % 2 == 0:
        return False
    for k in range(3, int(x ** 0.5) + 1, 2):
        if x % k == 0:
            return False
    return True


l, r = map(int, input().split())


ans = 0
for i in range(1, 10 ** 6 + 1):
    a = i
    b = i + 1
    if l <= a <= r and l <= b <= r:
        ab = a + b
        if is_prime(ab):
            ans += 1
    a = i
    b = i
    if l <= a <= r and l <= b <= r:
        if is_prime(a):
            ans += 1
print(ans)
0