結果
| 問題 |
No.1657 Sum is Prime (Easy Version)
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-08-30 11:03:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 515 bytes |
| コンパイル時間 | 6,012 ms |
| コンパイル使用メモリ | 337,164 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-23 03:31:39 |
| 合計ジャッジ時間 | 6,229 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
int main(){
int L,R;
cin>>L>>R;
vector<int> isPrime(2*R,1);
isPrime[1]=0;
for(int i=2;i<2*R;++i){
if(isPrime[i]){
for(int j=i*2;j<2*R;j+=i){
isPrime[j]=0;
}
}
}
int ans=0;
for(int i=L;i<R;i++){
ans+=isPrime[i];
ans+=isPrime[2*i+1];
}
ans+=isPrime[R];
cout<<ans<<endl;
}
ytft