結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー neterukunneterukun
提出日時 2021-08-27 21:36:35
言語 PyPy3
(7.3.13)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 524 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 78,440 KB
最終ジャッジ日時 2023-08-13 08:13:56
合計ジャッジ時間 14,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
75,996 KB
testcase_01 AC 81 ms
75,988 KB
testcase_02 AC 1,856 ms
78,440 KB
testcase_03 AC 81 ms
75,960 KB
testcase_04 AC 82 ms
76,196 KB
testcase_05 AC 79 ms
76,092 KB
testcase_06 AC 102 ms
77,092 KB
testcase_07 AC 98 ms
77,220 KB
testcase_08 AC 90 ms
76,560 KB
testcase_09 AC 92 ms
76,924 KB
testcase_10 AC 88 ms
76,436 KB
testcase_11 AC 130 ms
78,304 KB
testcase_12 AC 1,719 ms
77,888 KB
testcase_13 AC 711 ms
78,368 KB
testcase_14 AC 916 ms
78,364 KB
testcase_15 AC 1,167 ms
77,992 KB
testcase_16 AC 373 ms
77,856 KB
testcase_17 AC 172 ms
78,372 KB
testcase_18 AC 241 ms
77,972 KB
testcase_19 AC 1,739 ms
78,368 KB
testcase_20 AC 547 ms
77,992 KB
testcase_21 TLE -
testcase_22 AC 82 ms
75,704 KB
testcase_23 AC 328 ms
77,888 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