結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー とりゐとりゐ
提出日時 2021-08-27 21:51:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 91,668 KB
最終ジャッジ日時 2024-05-01 02:20:01
合計ジャッジ時間 4,299 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
87,808 KB
testcase_01 WA -
testcase_02 AC 137 ms
91,264 KB
testcase_03 AC 137 ms
87,680 KB
testcase_04 WA -
testcase_05 AC 107 ms
87,680 KB
testcase_06 AC 122 ms
88,448 KB
testcase_07 AC 129 ms
87,808 KB
testcase_08 AC 115 ms
87,680 KB
testcase_09 AC 122 ms
88,704 KB
testcase_10 AC 120 ms
88,960 KB
testcase_11 AC 116 ms
90,112 KB
testcase_12 AC 126 ms
91,008 KB
testcase_13 AC 130 ms
90,880 KB
testcase_14 AC 129 ms
91,392 KB
testcase_15 AC 124 ms
91,648 KB
testcase_16 AC 119 ms
91,008 KB
testcase_17 AC 118 ms
91,520 KB
testcase_18 AC 118 ms
91,668 KB
testcase_19 AC 117 ms
89,600 KB
testcase_20 AC 121 ms
91,008 KB
testcase_21 AC 107 ms
88,960 KB
testcase_22 AC 114 ms
88,832 KB
testcase_23 AC 136 ms
90,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#エラトステネスの篩
m=2*10**6
prime=[]
d=[-1]*(m+1)
for i in range(2,m+1):
  if d[i]==-1:
    d[i]=i
    prime.append(i)
    j=2
    while i*j<=m:
      d[i*j]=i
      j+=1
l,r=map(int,input().split())
ans=0
for i in prime:
  if i==2:
    if l<=2<=r:
      ans+=1
    continue
  if l<=i<=r:
    ans+=1
  if l<=(i+1)//2<=r:
    ans+=1
    #print(i)
print(ans)
0