結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー convexineqconvexineq
提出日時 2021-08-28 20:39:03
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 101,480 KB
最終ジャッジ日時 2023-08-14 03:15:49
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
100,672 KB
testcase_01 AC 113 ms
100,604 KB
testcase_02 AC 120 ms
101,220 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 110 ms
100,664 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 116 ms
100,472 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 115 ms
101,256 KB
testcase_12 AC 120 ms
101,476 KB
testcase_13 AC 120 ms
101,060 KB
testcase_14 AC 118 ms
101,480 KB
testcase_15 AC 122 ms
101,380 KB
testcase_16 AC 117 ms
101,176 KB
testcase_17 AC 117 ms
101,388 KB
testcase_18 AC 114 ms
101,380 KB
testcase_19 AC 118 ms
101,200 KB
testcase_20 AC 119 ms
101,224 KB
testcase_21 AC 125 ms
101,208 KB
testcase_22 AC 121 ms
100,260 KB
testcase_23 AC 118 ms
101,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes_is_prime_list(N): #N以下の素数のリストを返す
    #iが素数のときis_prime_list[i]=1,それ以外は0
    N+=1
    is_prime_list = [True]*N
    is_prime_list[0], is_prime_list[1] = False, False
    for j in range(4,N,2): is_prime_list[j] = False
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return is_prime_list

L,R = map(int,input().split())
M = 2*10**6 + 10
lst = Eratosthenes_is_prime_list(M)

ans = 0
for a in range(L,R+1):
    if lst[a]: ans += 1
    if lst[2*a+1]: ans += 1
print(ans)
0