結果
問題 | No.1657 Sum is Prime (Easy Version) |
ユーザー |
![]() |
提出日時 | 2021-08-27 22:58:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 3,747 ms |
コンパイル使用メモリ | 230,040 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 04:23:58 |
合計ジャッジ時間 | 4,914 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<int>>; #define MAX 2000000 #define MOD 998244353 #define INF 1000000000 vector<int> p; vector<bool> p_table(MAX+1,true); void prime(){ p_table.at(0)=false,p_table.at(1)=false; for(int i=2;i<=MAX;i++){ if(p_table.at(i)){ p.push_back(i); for(int j=2;i*j<=MAX;j++){ p_table.at(i*j)=false; } } } } int main(){ ll L,R; cin>>L>>R; prime(); int ans=0; for(int i=L;i<=R;i++){ if(p_table[i]){ ans++; } } for(int i=L;i<R;i++){ if(p_table[i+(i+1)]){ ans++; } } cout<<ans<<'\n'; }