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:AC了,代码如下, 这道题目不难

Posted by qdenis at 2009-03-16 09:16:11 on Problem 2262
In Reply To:AC了,代码如下, 这道题目不难 Posted by:382784268 at 2009-03-07 12:53:31
> #include<iostream>
> #include<cmath>
> using namespace std;
> int isprime(int a)
> {
> 	int flag=1;
> 	int i;
> 	for(i=2;i<=sqrt(double(a));i++)
> 	{
> 		if(a%i==0)
> 		{
> 			flag=0;
> 			break;
> 		}
> 	}
> 	return flag;
> }
> void result( int n,int *a)
> {
> 	int i;
> 	for(i=3;i<=n/2;i=i+2)
> 	{
> 	
> 		int flag=0;
> 		if(isprime(i))
> 		{
> 			flag++;
> 		}
> 		else
> 			continue;
> 		if(isprime(n-i))
> 		{
> 			flag++;
> 		}
> 		else
> 			continue;
> 		if(flag==2)
> 		{
> 			*a=i;
> 			break;
> 		}
> 	}
> 	
> }
> 
> 
> int  main()
> {
> 	int n;
> 	while(cin>>n&&n)
> 	{
> 		int a;
> 		result(n,&a);
> 		cout<<n<<" = "<<a<<" + "<<n-a<<endl;
> 	}
> 	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