結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー karinohitokarinohito
提出日時 2021-08-30 23:59:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 167,236 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 10:30:58
合計ジャッジ時間 16,316 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 TLE -
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 TLE -
testcase_13 AC 871 ms
5,376 KB
testcase_14 AC 1,065 ms
5,376 KB
testcase_15 AC 1,387 ms
5,376 KB
testcase_16 AC 301 ms
5,376 KB
testcase_17 AC 57 ms
5,376 KB
testcase_18 AC 155 ms
5,376 KB
testcase_19 TLE -
testcase_20 AC 564 ms
5,376 KB
testcase_21 TLE -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 283 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;

int main() {
    ll L,R;
    cin>>L>>R;
    ll an=0;
    for(ll A=L;A<=R-1;A++){
        ll P=2*A+1;
        bool C=true;
        for(ll i=2;i*i<=P;i++){
            if(P%i==0){
                C=false;
                break;
            }
        }
        if(C)an++;
    }
    for(ll A=L;A<=R;A++){
        ll P=A;
        bool C=true;
        for(ll i=2;i*i<=P;i++){
            if(P%i==0){
                C=false;
                break;
            }
        }
        if(C)an++;
    }
    cout<<an<<endl;
}
0