結果
| 問題 |
No.1657 Sum is Prime (Easy Version)
|
| コンテスト | |
| ユーザー |
inksamurai
|
| 提出日時 | 2021-08-27 21:33:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 239 ms / 2,000 ms |
| コード長 | 1,818 bytes |
| コンパイル時間 | 1,256 ms |
| コンパイル使用メモリ | 116,252 KB |
| 実行使用メモリ | 194,648 KB |
| 最終ジャッジ日時 | 2024-11-21 01:04:28 |
| 合計ジャッジ時間 | 6,422 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
#include <cstring>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3kynfAJ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
using pii=pair<int,int>;
using vi=vec(int);
const int mxn=7000002;
vec(vec(pii)) prmfct;
vi prm;
void fdprm(int nupto) {
//glblhere
//
//glblhere
prmfct.clear();
prmfct.resize(nupto+3,vec(pii)());
prm.resize(nupto+3,0);
crep(i,2,sqrt(nupto)+1){
if(prm[i]==0){
for(int j=i*i;j<=nupto;j+=i) prm[j] = i;
}
}
crep(i,2,nupto+1) if(prm[i]==0) prm[i]=i;
// crep(i,2,nupto+1){
// int x=i,y=0,pup=0,cnt=0;
// while(x!=1) {
// y=prm[x],pup=y;
// if(y==0) break;
// cnt=0;
// while(y!=0 and x%y==0) {x/=y;cnt++;}
// prmfct[i].pb({pup,cnt});
// }
// }
}
int main(){
_3kynfAJ;
fdprm(mxn);
int a,b;
cin>>a>>b;
int ans=0;
crep(x,a,b+1){
int s=0;
// cout<<x<<"\n";
for(int j=x;j<=x+5;j++){
if(j>b) break;
s+=j;
if(prm[s]==s){
ans=ans+1;
}
}
}
cout<<ans<<"\n";
//
return 0;
}
inksamurai