- #include <bits/stdc++.h>
- using namespace std;
- #define N 10000000
- bool prime[N];
- vector<int> v;
- void sieve(){
- memset(prime, true, sizeof(prime));
- for(int i = 2; i <=sqrt(N); i++){
- for(int j = i*i; j<= N; j+= i){
- prime[j] = false;
- }
- }
- for(int i = 2; i <=N; i++){
- if(prime[i]) v.push_back(i);
- }
- //for(int i = 0; i <v.size(); i++) cout<<v[i]<<" ";
- }
- int main()
- {
- int t,cases=0;
- sieve();
- scanf("%d",&t);
- while(t--){
- int n;
- scanf("%d", &n);
- /*
- if(a*a == b*b + c*c || b*b == a*a + c*c || c*c== a*a + b*b) printf("Case %d: yes\n",++cases);
- else printf("Case %d: no\n",++cases);
- */
- int c = 0;
- for(int i = 0; v[i]<= n-v[i]; i++){
- if(prime[n-v[i]]) c++;
- }
- printf("Case %d: %d\n",++cases, c);
- }
- return 0;
- }
Friday, 28 July 2017
Lightoj 1259 - Goldbach`s Conjecture
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment