結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー convexineqconvexineq
提出日時 2021-08-28 20:39:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 90,180 KB
最終ジャッジ日時 2024-05-01 16:07:23
合計ジャッジ時間 3,362 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
87,680 KB
testcase_01 AC 101 ms
86,324 KB
testcase_02 AC 108 ms
89,536 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 96 ms
86,984 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 95 ms
86,992 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 98 ms
88,328 KB
testcase_12 AC 106 ms
89,616 KB
testcase_13 AC 101 ms
90,060 KB
testcase_14 AC 105 ms
88,644 KB
testcase_15 AC 101 ms
88,820 KB
testcase_16 AC 102 ms
89,404 KB
testcase_17 AC 100 ms
89,420 KB
testcase_18 AC 99 ms
89,260 KB
testcase_19 AC 104 ms
90,180 KB
testcase_20 AC 99 ms
89,808 KB
testcase_21 AC 104 ms
88,704 KB
testcase_22 AC 91 ms
88,228 KB
testcase_23 AC 94 ms
89,576 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