hdu1262-寻找素数对

http://acm.hdu.edu.cn/showproblem.php?pid=1262

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<iomanip>

using namespace std;

int judge( int n )
{
		for( int i = 2 ; i <= sqrt( n ) ; ++i )
		{
			if( n % i == 0 )
				return 0 ;
		}
		return 1 ;
}

int main()
{
	int n ;
	while( cin >> n )
	{
		for( int i = n / 2 ; i <= n ; ++i )
		{
			if( judge( i ) && judge( n - i ) )
			{
				cout << n - i << " " << i << endl ;
				break ;
			} 
		}
	}
		return 0 ;
}


你可能感兴趣的:(Prime)