結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー abc3abc3
提出日時 2021-08-27 23:36:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,080 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 201,744 KB
実行使用メモリ 11,084 KB
最終ジャッジ日時 2024-05-01 04:23:00
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 23 ms
10,800 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 22 ms
10,740 KB
testcase_13 AC 12 ms
7,164 KB
testcase_14 AC 17 ms
9,468 KB
testcase_15 AC 19 ms
9,696 KB
testcase_16 AC 9 ms
6,944 KB
testcase_17 AC 12 ms
6,944 KB
testcase_18 AC 11 ms
6,944 KB
testcase_19 AC 20 ms
10,060 KB
testcase_20 AC 13 ms
8,060 KB
testcase_21 AC 24 ms
11,016 KB
testcase_22 AC 27 ms
11,084 KB
testcase_23 AC 26 ms
10,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=998244353;

    void solve(){
        int l,r;
        cin>>l>>r;
        vector<int>seen(2*r+5);
        for(int i=2;i<=2*r+1;i++){
            if(seen[i]){continue;}
            for(int j=i*2;j<=2*r+1;j+=i){
                seen[j]=1;
            }
        }
        int cnt=0;
        for(int i=l;i<=r;i++){
            if(i>1&&!seen[i]){cnt++;}
            if(!seen[i*2+1]){cnt++;}
        }
        cout<<cnt<<endl;
    }  

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();
        
        return 0;
    }
0