結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー DrDrpilotDrDrpilot
提出日時 2022-02-10 14:44:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 115,320 KB
最終ジャッジ日時 2023-09-08 03:55:06
合計ジャッジ時間 5,124 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,108 KB
testcase_01 AC 68 ms
71,452 KB
testcase_02 AC 247 ms
112,036 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,344 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 78 ms
76,780 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 81 ms
76,876 KB
testcase_12 AC 242 ms
111,812 KB
testcase_13 AC 150 ms
95,664 KB
testcase_14 AC 193 ms
107,548 KB
testcase_15 AC 199 ms
107,724 KB
testcase_16 AC 121 ms
91,256 KB
testcase_17 AC 123 ms
93,132 KB
testcase_18 AC 126 ms
95,344 KB
testcase_19 AC 232 ms
110,336 KB
testcase_20 AC 155 ms
100,540 KB
testcase_21 AC 259 ms
115,320 KB
testcase_22 AC 177 ms
114,916 KB
testcase_23 AC 190 ms
115,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l,r=map(int,input().split())
c=2*r+1
prime=[True]*(c+1)
prime[0]=False;prime[1]=False
primes=set()
for i in range(2,c+1):
    if prime[i]:
        primes.add(i)
        for j in range(2*i,c+1,i):
            prime[j]=False
ans=0
for a in range(l,r+1):
    if a in primes:
        ans+=1
    if 2*a+1 in primes:
        ans+=1
print(ans)
0