結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー 👑 timitimi
提出日時 2021-09-13 17:02:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 92,004 KB
最終ジャッジ日時 2023-09-08 00:22:30
合計ジャッジ時間 4,765 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
91,532 KB
testcase_01 AC 108 ms
91,896 KB
testcase_02 AC 119 ms
91,844 KB
testcase_03 AC 108 ms
91,924 KB
testcase_04 AC 110 ms
91,692 KB
testcase_05 AC 112 ms
92,004 KB
testcase_06 AC 114 ms
91,924 KB
testcase_07 AC 110 ms
91,924 KB
testcase_08 AC 113 ms
91,668 KB
testcase_09 AC 110 ms
91,680 KB
testcase_10 AC 109 ms
91,536 KB
testcase_11 AC 112 ms
91,928 KB
testcase_12 AC 120 ms
91,768 KB
testcase_13 AC 116 ms
91,624 KB
testcase_14 AC 115 ms
91,560 KB
testcase_15 AC 114 ms
91,664 KB
testcase_16 AC 118 ms
91,892 KB
testcase_17 AC 110 ms
91,736 KB
testcase_18 AC 112 ms
91,708 KB
testcase_19 AC 120 ms
91,932 KB
testcase_20 AC 113 ms
91,916 KB
testcase_21 AC 120 ms
91,936 KB
testcase_22 AC 105 ms
91,872 KB
testcase_23 AC 109 ms
91,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L,R=map(int, input().split())
ans=0
D=[1]*(2*10**6+10)
D[0]=0
D[1]=0
for i in range(2,10**6+1):
  cnt=2
  if D[i]==1:
    while i*cnt<=2*10**6+5:
      D[i*cnt]=0
      cnt+=1
ans=0
if D[R]==1:
  ans+=1
for l in range(L,R):
  if D[l]==1:
    ans+=1
  a=2*l+1
  if D[a]==1:
    ans+=1
print(ans)
0