mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 2262_ACShiryu.cpp
From http://www.cnblogs.com/ACShiryu/archive/2011/08/04/2127966.html
This commit is contained in:
parent
ad580fad11
commit
3a5bd97e46
29
POJ/2262_ACShiryu.cpp
Normal file
29
POJ/2262_ACShiryu.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include<iostream>
|
||||
#include<cstdlib>
|
||||
#include<cstdio>
|
||||
#include<cstring>
|
||||
#include<algorithm>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
bool isprime ( int k )
|
||||
{
|
||||
int t = sqrt ( k + 0.5 ) ;
|
||||
for ( int i = 2 ; i <= t ; i ++ )
|
||||
if ( k % i == 0 )
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n ;
|
||||
while ( scanf ("%d", &n) , n )
|
||||
{
|
||||
int i ;
|
||||
int t = n / 2 ;
|
||||
for ( i = 3 ; i <= t ; i += 2 )
|
||||
if ( isprime ( i ) && isprime ( n - i ) )
|
||||
break ;
|
||||
printf ( "%d = %d + %d\n" , n , i , n - i ) ;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user