T122399 Goldbach's conjecture
Meaning of the questions: give you n, let your card Goldbach conjecture, 1e9 complexity;
This question of how complicated calculation is not right, not a linear array that big screen,
and then surprised the violence actually passed.
Proof follows:
log (n) too soon Yeah, about 1e9 also 30, so count on the right;
#include<bits/stdc++.h> using namespace std; bool isprime(int x){ for(int i=2;i*i<=x;i++){ if(x%i==0)return 0; } return 1; } int main(){ int n; cin>>n; for(int i=2;i*i<n;i++){ if(isprime(i)&&isprime(n-i)){ cout<<i<<" "<<n-i<<endl; break; } } return 0; }
T122397 Everybody deserves a long long name
T122394 Billionaire
Meaning of the questions: is to ask how many days you can become a billionaire, output date.
Solution: separation of two days, and then by seeking the date zeller formula;
I'm stuck here for a while, is two points, the biggest blind zone is not selected, think also understand that I started to get a lot, he would skip the correct answer,
Therefore, if r sqrt (2e9), solving the equation to obtain;
Although half fast, but you can not choose a large range, otherwise the answer is not right, L small, R big, will skip the correct answer,
#include<bits/stdc++.h> using namespace std; int getId(int y, int m, int d) { if (m < 3) {y --; m += 12;} return 365 * y + y / 4 - y / 100 + y / 400 + (153 * (m - 3) + 2) / 5 + d - 307; } vector<int> date(int id) { int x = id + 1789995, n, i, j, y, m, d; n = 4 * x / 146097; x -= (146097 * n + 3) / 4; i = (4000 * (x + 1)) / 1461001; x -= 1461 * i / 4 - 31; j = 80 * x / 2447; d = x - 2447 * j / 80; x = j / 11; m = j + 2 - 12 * x; y = 100 * (n - 49) + i + x; vector<int>v; v.push_back(y),v.push_back(m),v.push_back(d); return v; } int m; const int maxn=1000000000; bool check(int x){ int sum=m+x*(x+1)/2; if(sum>=maxn)return 1; else return 0; } int main(){ int t; cin>>t; while(t--){ int ty,tm,td; scanf("%d %d %d %d",&m,&ty,&tm,&td); int id=getId(ty,tm,td); int l=0,r=sqrt(2e9); while(l<=r){ int mid=(r+l)/2; if(check(mid))r=mid-1; else l=mid+1; } id+=l; vector<int>ans=date(id); printf("%d %d %d\n",ans[0],ans[1],ans[2]); } // system("pause"); return 0; }
T122398 Final Spark
This question about such a question:
That is launching a light, and asked to be shot in the probability that you are. The person radius r, the radius of hop s, lightwave width w, the distance d,
Useless distance d, w + 2r problem is converted into the optical wave how inscribed circle, the maximum coverage area.
pending upgrade;