From 3a5bd97e46d6abf2bd652e62763e82bfd2637394 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 6 May 2017 06:02:52 +0800 Subject: [PATCH] Create 2262_ACShiryu.cpp From http://www.cnblogs.com/ACShiryu/archive/2011/08/04/2127966.html --- POJ/2262_ACShiryu.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 POJ/2262_ACShiryu.cpp diff --git a/POJ/2262_ACShiryu.cpp b/POJ/2262_ACShiryu.cpp new file mode 100644 index 0000000..0891825 --- /dev/null +++ b/POJ/2262_ACShiryu.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +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; +}