結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー sigmanisigmani
提出日時 2022-03-05 21:23:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 173,668 KB
実行使用メモリ 10,400 KB
最終ジャッジ日時 2023-09-27 09:47:06
合計ジャッジ時間 7,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 365 ms
7,280 KB
testcase_15 WA -
testcase_16 AC 110 ms
4,892 KB
testcase_17 AC 21 ms
4,380 KB
testcase_18 AC 54 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 194 ms
5,500 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 96 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
bool isPrime(int x){
if(x==1)return 0;
if(x==2)return 1;
for(int i=2;i*i<=x;i++)if(x%i==0)return 0;
return 1;
}
int main(){
  int L,R;
  cin>>L>>R;
  int count=0;
  map<int,int>Map;
  for(int i=L;i<=R;i++){
    if(isPrime(i)==1){
      Map[i]++;
      count++;
      }
    }
  for(int i=L;i<=R;i++)if(isPrime(2*i+1)==1&&Map[2*i+1]==0)count++;
  cout<<count;
}
0