Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:直接搜……454ms

Posted by qylsw at 2010-07-11 09:55:16 on Problem 2909
In 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator