标签:title class nbsp log math scan target targe 偶数
此博客链接:https://www.cnblogs.com/ping2yingshi/p/12384918.html
分拆素数和(28min)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2098
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> int IsPrim(int x) { int i; int flag = 1; for (i = 2; i <= sqrt(x); i++) { if (x % i == 0)//判断是不是素数 flag = 0; } return flag; } int main() { int n; while (~scanf_s("%d",&n)) { if (n == 0) break; int a; int b; int count=0;//计算满足条件数量 for (a = 2; a < n / 2; a++) { b = n - a; if (IsPrim(a) && IsPrim(b)) { count++; } } printf("%d\n", count); } return 0; }
标签:title class nbsp log math scan target targe 偶数
原文地址:https://www.cnblogs.com/ping2yingshi/p/12384918.html