| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
0ms做法In Reply To:一次ac,不过要16ms,求0ms做法 Posted by:TSERROF at 2012-09-10 14:54:31 #include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
bool b[40000];
int a[40000]={0},len=0,n;
bool f(int n){
for(int i=2;i*i<=n;i++)
if(n%i==0) return false;
return true;
}
int main(){
memset(b,false,sizeof(b));
for(int i=2;i<=pow(2,15);i++)
if(f(i)){
a[len++]=i;
b[i]=true;
}
while(cin>>n&&n>=4&&n<pow(2,15)){
int num=0;
for(int i=0;a[i]<=n/2;i++)
if(b[a[i]]&&b[n-a[i]]) num++;
cout<<num<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator