結果
問題 |
No.1657 Sum is Prime (Easy Version)
|
ユーザー |
|
提出日時 | 2021-08-31 00:01:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 1,435 ms |
コンパイル使用メモリ | 169,768 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 09:42:57 |
合計ジャッジ時間 | 2,484 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#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; vector<bool> P(2*1000000+5,true); P[0]=P[1]=false; rep(i,2e6+5){ if(P[i]){ for(ll j=i+i;j<=2e6+5;j+=i){ P[j]=false; } } } for(ll A=L;A<=R-1;A++){ if(P[2*A+1])an++; } for(ll A=L;A<=R;A++){ if(P[A])an++; } cout<<an<<endl; }