| ||||||||||
| 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 | |||||||||
Re:直接搜……454msIn Reply To:直接搜……454ms Posted by:tankadozmy at 2010-02-12 12:43:19 #include<iostream>
#include<math.h>
using namespace std;
int f(int n)
{
double m=n;
int i;
for(i=2;i<=int(sqrt(m)+1);i++)
if(n%i==0) break;
if(i>=int(sqrt(m)+1)) return 1;
else return 0;
}
int main()
{
int x;
while(scanf("%d",&x)&&x!=0){
int c=0;
for(int s=2;s<=x/2;s++)
{if(f(s)==1&&f(x-s)==1)
c+=1;}
printf("%d\n",c);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator