poj2739
来源:互联网 发布:淘宝做代理发货怎么办 编辑:程序博客网 时间:2024/05/16 07:42
//poj2739 还是关于素数 打表先。 #include <iostream>#include <string>#include <iomanip>#include <cmath>using namespace std;int a[10005];bool prime(int k){for(int i = 2; i < sqrt(k*1.0) + 1; i++){if(k % i == 0){return false;}}return true;}void list(){int k = 2;a[0] = 2;a[1] = 3;for(int i = 5; i < 10005; i++){if(prime(i))a[k++] = i;}}int main(){list();int n;cin>>n;while(n){int ans = 0;int total = 0;for(int i = 0; a[i] <= n; i++){total = 0;for(int j = i; total <= n; j++){total += a[j];if(total == n){ans++;}}}cout<<ans<<endl;cin>>n;} return 0;}
0 0
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- POJ2739
- POJ2739
- POJ2739
- poj2739
- poj2739
- POJ2739
- poj2739
- poj2739
- poj2739
- hduoj1754
- 《网蜂A8实战演练》——10.Linux 网络设备驱动
- TEST
- Mysql分页之limit用法与limit优化
- 软工文档总结
- poj2739
- 滑动改变ViewPager背景颜色
- android主题和样式
- poj1083
- 最小生成树-Prim算法和Kruskal算法
- poj2262
- js深入学习专题 ------ 类数组的对象和数组对象的区别和联系
- poj1503
- 汉诺塔