結果
問題 | No.732 3PrimeCounting |
ユーザー | %20 |
提出日時 | 2018-09-14 13:28:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 6,489 bytes |
コンパイル時間 | 2,718 ms |
コンパイル使用メモリ | 215,976 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-07-05 01:06:13 |
合計ジャッジ時間 | 75,642 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
9,728 KB |
testcase_01 | AC | 7 ms
5,376 KB |
testcase_02 | AC | 7 ms
5,376 KB |
testcase_03 | AC | 7 ms
5,376 KB |
testcase_04 | AC | 6 ms
5,376 KB |
testcase_05 | AC | 7 ms
5,376 KB |
testcase_06 | AC | 8 ms
5,376 KB |
testcase_07 | AC | 8 ms
5,376 KB |
testcase_08 | AC | 8 ms
5,376 KB |
testcase_09 | AC | 8 ms
5,376 KB |
testcase_10 | AC | 8 ms
5,376 KB |
testcase_11 | AC | 8 ms
5,376 KB |
testcase_12 | AC | 8 ms
5,376 KB |
testcase_13 | AC | 9 ms
5,376 KB |
testcase_14 | AC | 9 ms
5,376 KB |
testcase_15 | AC | 9 ms
5,376 KB |
testcase_16 | AC | 9 ms
5,376 KB |
testcase_17 | AC | 9 ms
5,376 KB |
testcase_18 | AC | 9 ms
5,376 KB |
testcase_19 | AC | 9 ms
5,376 KB |
testcase_20 | AC | 54 ms
5,376 KB |
testcase_21 | AC | 160 ms
5,376 KB |
testcase_22 | AC | 159 ms
5,376 KB |
testcase_23 | AC | 24 ms
5,376 KB |
testcase_24 | AC | 24 ms
5,376 KB |
testcase_25 | AC | 279 ms
5,376 KB |
testcase_26 | AC | 209 ms
5,376 KB |
testcase_27 | AC | 71 ms
5,376 KB |
testcase_28 | AC | 72 ms
5,376 KB |
testcase_29 | AC | 134 ms
5,376 KB |
testcase_30 | AC | 134 ms
5,376 KB |
testcase_31 | AC | 170 ms
5,376 KB |
testcase_32 | AC | 231 ms
5,376 KB |
testcase_33 | AC | 232 ms
5,376 KB |
testcase_34 | AC | 235 ms
5,376 KB |
testcase_35 | AC | 185 ms
5,376 KB |
testcase_36 | AC | 188 ms
5,376 KB |
testcase_37 | AC | 38 ms
5,376 KB |
testcase_38 | AC | 39 ms
5,376 KB |
testcase_39 | AC | 193 ms
5,376 KB |
testcase_40 | AC | 177 ms
5,376 KB |
testcase_41 | AC | 178 ms
5,376 KB |
testcase_42 | AC | 173 ms
5,376 KB |
testcase_43 | AC | 146 ms
5,376 KB |
testcase_44 | AC | 142 ms
5,376 KB |
testcase_45 | AC | 87 ms
5,376 KB |
testcase_46 | AC | 84 ms
5,376 KB |
testcase_47 | AC | 103 ms
5,376 KB |
testcase_48 | AC | 304 ms
5,376 KB |
testcase_49 | AC | 292 ms
5,376 KB |
testcase_50 | AC | 164 ms
5,376 KB |
testcase_51 | AC | 168 ms
5,376 KB |
testcase_52 | AC | 80 ms
5,376 KB |
testcase_53 | AC | 550 ms
5,376 KB |
testcase_54 | AC | 2,412 ms
5,376 KB |
testcase_55 | AC | 2,427 ms
5,376 KB |
testcase_56 | AC | 2,444 ms
5,376 KB |
testcase_57 | AC | 1,009 ms
5,376 KB |
testcase_58 | AC | 1,017 ms
5,376 KB |
testcase_59 | AC | 572 ms
5,376 KB |
testcase_60 | AC | 1,260 ms
5,376 KB |
testcase_61 | AC | 1,264 ms
5,376 KB |
testcase_62 | AC | 2,782 ms
5,376 KB |
testcase_63 | AC | 1,778 ms
5,376 KB |
testcase_64 | AC | 1,458 ms
5,376 KB |
testcase_65 | AC | 1,466 ms
5,376 KB |
testcase_66 | AC | 21 ms
5,376 KB |
testcase_67 | AC | 21 ms
5,376 KB |
testcase_68 | AC | 2,620 ms
5,376 KB |
testcase_69 | AC | 2,598 ms
5,376 KB |
testcase_70 | AC | 2,476 ms
5,376 KB |
testcase_71 | AC | 2,452 ms
5,376 KB |
testcase_72 | AC | 1,735 ms
5,376 KB |
testcase_73 | TLE | - |
testcase_74 | TLE | - |
testcase_75 | AC | 271 ms
5,376 KB |
testcase_76 | AC | 2,568 ms
5,376 KB |
testcase_77 | AC | 1,057 ms
5,376 KB |
testcase_78 | TLE | - |
testcase_79 | AC | 2,602 ms
5,376 KB |
testcase_80 | AC | 2,975 ms
5,376 KB |
testcase_81 | AC | 2,524 ms
5,376 KB |
testcase_82 | AC | 65 ms
5,376 KB |
testcase_83 | AC | 1,028 ms
5,376 KB |
testcase_84 | AC | 1,101 ms
5,376 KB |
testcase_85 | AC | 2,227 ms
5,376 KB |
testcase_86 | AC | 2,980 ms
5,376 KB |
testcase_87 | TLE | - |
testcase_88 | -- | - |
ソースコード
#include<bits/stdc++.h> #define fr(i,n) for(int i=0;i<(n);++i) #define foor(i,a,b) for(int i=(a);i<=(b);++i) #define rf(i,n) for(int i=(n);i--;) #define roof(i,b,a) for(int i=(b);i>=(a);--i) #define elsif else if #define all(x) x.begin(),x.end() #define Sort(x) sort(all(x)) #define Reverse(x) reverse(all(x)) #define PQ priority_queue #define NP(x) next_permutation(all(x)) using namespace std; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector< ll> vl; typedef vector<vl> vvl; typedef unsigned long long ull; typedef vector<ull> vu; typedef vector<vu> vvu; typedef double dbl; typedef vector<dbl> vd; typedef vector<vd> vvd; typedef string str; typedef vector<str> vs; typedef vector<vs> vvs; typedef pair<int,int>pii; typedef vector<pii>vpii; typedef map<int,int>mii; typedef pair< ll, ll>pll; typedef vector<pll>vpll; typedef map< ll, ll>mll; typedef pair<dbl,dbl>pdd; typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd; typedef pair<str,str>pss; typedef vector<pss>vpss; typedef map<str,str>mss; typedef pair<int, ll>pil; typedef vector<pil>vpil; typedef map<int, ll>mil; typedef pair< ll,int>pli; typedef vector<pli>vpli; typedef map< ll,int>mli; typedef pair<dbl,int>pdi; typedef vector<pdi>vpdi; typedef map<dbl,int>mdi; template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;} template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;} template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;} template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;} template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;} template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;} template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;} template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;} template<typename T,typename U>pair<T,U>operator+(pair<T,U>a,pair<T,U>b){return {a.first+b.first,a.second+b.second};} template<typename T,typename U>pair<T,U>operator-(pair<T,U>a,pair<T,U>b){return {a.first-b.first,a.second-b.second};} template<typename T>void print(T x){cout<<x<<endl;} template<typename T,typename U>void print(T x,U y){cout<<x<<" "<<y<<endl;} template<typename T,typename U,typename V>void print(T x,U y,V z){cout<<x<<" "<<y<<" "<<z<<endl;} const int MD=1e9+7; template<typename T>str to_string(const T&n){ostringstream s;s<<n;return s.str();} template<typename T,typename U>vector<pair<T,U>>dijkstra(const vector<vector<pair<T,U>>>E,const U s,const T inf){using P=pair<T,U>;vector<P>d;fr(i,E.size()){d<<P{inf,i};}PQ<P,vector<P>,greater<P>>pq;pq<<(d[s]=P{0,s});while(pq.size()){P a=pq.top();pq.pop();U v=a.second;if(d[v].first>=a.first){for(P e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=P{d[v].first+e.first,v};pq<<P{d[v].first+e.first,e.second};}}}}return d;} template<typename T,typename U>map<U,pair<T,U>>dijkstra(map<U,vector<pair<T,U>>>E,const U s,const T inf){using P=pair<T,U>;map<U,P>d;for(pair<U,vector<P>>e:E){d[e.first]=P{inf,e.first};}PQ<P,vector<P>,greater<P>>pq;pq<<(d[s]=P{0,s});while(pq.size()){P a=pq.top();pq.pop();U v=a.second;if(d[v].first>=a.first){for(P e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=P{d[v].first+e.first,v};pq<<P{d[v].first+e.first,e.second};}}}}return d;} template<typename T>T distsq(pair<T,T>a,pair<T,T>b){return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);} template<typename T>T max(const vector<T>a){T m=a[0];for(T e:a){m=max(m,e);}return m;} template<typename T>T min(const vector<T>a){T m=a[0];for(T e:a){m=min(m,e);}return m;} template<typename T>T gcd(const T a,const T b){return a?gcd(b%a,a):b;} template<typename T>T gcd(const vector<T>a){T g=a[0];for(T e:a){g=gcd(g,e);}return g;} template<typename T>vector<T>LIS(const vector<T>A){vi B;for(T a:A){auto it=lower_bound(all(B),a);if(it==B.end()){B<<a;}else{*it=a;}}return B;} ll strmod(const str&s,const int m){ll x=0;fr(i,s.size()){x=(x*10+s[i]-48)%m;}return x;} vvl mul(const vvl&A,const vvl&B,const int m){vvl C;fr(y,A.size()){C<<vl(B[y].size());}fr(y,C.size()){fr(x,C[y].size()){fr(i,A[0].size()){(C[y][x]+=A[y][i]*B[i][x])%=m;}}}return C;} vvl pow(const vvl&A,const ll n,const int m){vvl B;fr(y,A.size()){B<<vl(A.size());}if(n==0){fr(i,B.size()){B[i][i]=1;}}elsif(n%2){B=mul(A,pow(A,n-1,m),m);}else{vvl C=pow(A,n/2,m);B=mul(C,C,m);}return B;} ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:!!a;} ll inv(const ll x,const int p){return pow(x,p-2,p);} vpll fact(const int n,const int p){vpll v(n+1);v[0].first=1;foor(i,1,n){v[i].first=v[i-1].first*i%p;}v[n].second=inv(v[n].first,p);roof(i,n,1){v[i-1].second=v[i].second*i%p;}return v;} ll C2(const int n){return(ll)n*~-n/2;} ll sum(const vi a){ll s=0;for(int e:a){s+=e;}return s;} ll sum(const vl a){ll s=0;for(ll e:a){s+=e;}return s;} ll segsum(vl&s,int l,int r){l|=s.size()>>1;r|=s.size()>>1;if(l>r){return 0;}if(l==r){return s[l];}ll z=s[l]+s[r];for(;l>>1<r>>1;l>>=1,r>>=1){l&1||(z+=s[l^1]);r&1&&(z+=s[r^1]);}return z;} void segadd(vl&s,int i,ll x){s[i|=s.size()>>1]+=x;for(;i>>1>=1;i>>=1){s[i>>1]=s[i]+s[i^1];}} ll BITsum(vl&B,int i){ll z=0;while(i>0){z+=B[i];i-=i&-i;}return z;} void BITadd(vl&B,int i,ll x){while(i<B.size()){B[i]+=x;i+=i&-i;}} ll fib(const ll n,const int m){ll a,b,c,d,A,B,C,D;a=1;b=0;c=0;d=1;rf(i,63){A=a*a+b*c;B=a*b+b*d;C=c*a+d*c;D=c*b+d*d;if(n>>i&1){a=A;b=B;c=C;d=D;A=a+b;B=a;C=c+d;D=c;}a=A%m;b=B%m;c=C%m;d=D%m;}return b;} vi primes(int n){vb b(n+1);vi p;foor(i,2,n){if(!b[i]){p<<i;for(int j=2*i;j<=n;j+=i){b[j]=true;}}}return p;} vb isprime(const int n){vb v(n+1,true);v[0]=v[1]=false;foor(i,2,n){if(v[i]){for(int j=2*i;j<=n;j+=i){v[j]=false;}}}return v;} // (int) * (int) => (int) // (int) / (int) => (int) int main(){cin.tie(0);ios::sync_with_stdio(false); int N; cin>>N; vi p=primes(200000); vb isp=isprime(300000); vi x(300000); ll z=0; for(int c=3;p[c]<=N;++c){ int b=c-1; foor(a,1,b-1){ ++x[p[a]+p[b]]; } for(int ab=8;ab<200000;ab+=2){ if(isp[ab+p[c]]){ z+=x[ab]; } } } print(z); return 0; }