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 20110706 at 2011-12-13 20:41:56 on Problem 2262
#include<iostream>
using namespace std;
int isprime(int num)
{
	for(int i=2;i*i<=num;i++)
		if(num%i==0)
			return 0;
	return 1;
}
int main()
{
	int m;
	while(cin>>m&&m)
	{
		for(int i=2;i<=m/2;i++)
			if(isprime(i)&&isprime(m-i))
			{
				cout<<m<<" = "<<i<<" + "<<m-i<<endl;
				break;
			}
	}
}

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