結果
| 問題 |
No.1657 Sum is Prime (Easy Version)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-07 00:22:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 2,087 ms |
| コンパイル使用メモリ | 195,388 KB |
| 最終ジャッジ日時 | 2025-02-07 22:26:57 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int L,R;
cin>>L>>R;
vector<bool>prime(R*2,true);
prime[1]=false;
for(long long i=2;i<R*2;i++){
if(!prime[i])continue;
for(long long j=i*i;j<R*2;j+=i)prime[j]=false;
}
int ans=0;
for(int i=L;i<=R;i++){
if(prime[i])++ans;
}
for(int i=L;i<R;i++){
if(prime[i*2+1])++ans;
}
cout<<ans<<'\n';
}