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

用G++能过,用C,C++提示CR 汗颜!!!

Posted by huhuhuhh at 2010-02-28 19:16:25 on Problem 2909
#include<stdio.h>
#include<math.h>
bool is_prime(int n){
	int i;
	for(i=2;i<=(int)sqrt(n);i++)
		if(n%i==0)
			break;
	if(i>(int)sqrt(n))
		return 1;
	else 
		return 0;
}
int main()
{
	int n,i;
	while(1==scanf("%d",&n)&&n!=0){
		int count=0;
		for(i=2;i<=n/2;i++)
			if(is_prime(i)&&is_prime(n-i))
				count++;
		printf("%d\n",count);
		}
		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