From 8cf70674830bf2d266cdb397f988ead3e847d4d0 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 21 May 2016 12:40:11 +0800 Subject: [PATCH] Create 1734.c --- QUSTOJ/1734.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 QUSTOJ/1734.c diff --git a/QUSTOJ/1734.c b/QUSTOJ/1734.c new file mode 100644 index 0000000..291536b --- /dev/null +++ b/QUSTOJ/1734.c @@ -0,0 +1,36 @@ +#include + +//Written by Coffee. 判断素数 +int isPrime(int num) +{ + if (num == 2 || num == 3) + { + return 1; + } + if (num % 6 != 1 && num % 6 != 5) + { + return 0; + } + for (int i = 5; i*i <= num; i += 6) + { + if (num % i == 0 || num % (i+2) == 0) + { + return 0; + } + } + return 1; +} + +int main() +{ + int a; + scanf("%d",&a); + for(int i=2;i<=a/2;i++) + { + if(isPrime(i)&&isPrime(a-i)) + { + printf("%d=%d+%d\n",a,i,a-i); + } + } + return 0; +}