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

帮忙看下怎么会超时呢

Posted by tangwenwu at 2011-03-28 19:23:34 on Problem 2262
#include<stdio.h>
int prime(int k){
	int flag=1;
	int j;
	for(j=2;j<=k/2;j++){
			if(k%j==0){
				flag=0;
			break;
	}
	}
				return flag;
			}
int main(){
int i,n,f=0;
	for(scanf("%d",&n);n!=0;scanf("%d",&n)){
		for(i=3;i<=n/2;i=i+2){
			if(prime(i)&&prime(n-i)){
		printf("%d = %d + %d\n",n,i,n-i);
		f=1;
		break;
			}
		}
		if(!f)
			printf("Goldbach's conjecture is wrong.\n");
			}
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