poj 2739 Sum of Consecutive Prime Numbers (最大连续素数和)
来源:互联网 发布:如何注册成为淘宝达人 编辑:程序博客网 时间:2024/04/29 00:05
点击打开链接
打表+求和..
#include"stdio.h"#include"math.h"int prime[10010];int count;void fun(){ count=0; int i,j,k; for(i=2;i<=10000;i++) { k=(int)sqrt(i); int flag=1; for(j=2;j<=k;j++) { if(i%j==0) { flag=0; break; } } if(flag==1) prime[count++]=i; }}int main(){ int cas; int n; int i,l; int sum; fun(); while(scanf("%d",&n)!=EOF&&n) { int m; m=0;cas=0; for(l=0;l<count;l++) { sum=0; if(prime[l]>n) break; for(i=l;i<count;i++) { sum+=prime[i]; if(sum==n) { cas++;break; } else if(sum>n) break; } } printf("%d\n",cas); } return 0;}
- poj 2739 Sum of Consecutive Prime Numbers (最大连续素数和)
- POJ 2739 Sum of Consecutive Prime Numbers-数论-(连续素数和)
- POJ 2739 Sum of Consecutive Prime Numbers(连续素数和)
- POJ 2739: Sum of Consecutive Prime Numbers - 素数和
- POJ 2739 Sum of Consecutive Prime Numbers(素数打表水题)
- POJ 2739 Sum of Consecutive Prime Numbers(线性素数筛+前缀和)
- POJ 2739 Sum of Consecutive Prime Numbers(素数序列和,尺取法)
- POJ 2739 Sum of Consecutive Prime Numbers(素数表)
- poj 2739 Sum of Consecutive Prime Numbers(筛选素数 预处理)
- poj 2739 Sum of Consecutive Prime Numbers【素数筛】
- POJ 2739 Sum of Consecutive Prime Numbers(素数)
- POJ 2739—Sum of Consecutive Prime Numbers (素数)
- UVa 1210 - Sum of Consecutive Prime Numbers(素数+连续和)
- POJ 2739 Sum of Consecutive Prime Numbers(素数打表+素数搜索)
- POJ 2739 - Sum of Consecutive Prime Numbers(素数筛法+前缀和 / 尺取法)
- poj Sum of Consecutive Prime Numbers 2739 (素数打表)
- poj 2739 Sum of Consecutive Prime Numbers(尺取+筛素数)
- POJ 2739(Sum of Consecutive Prime Numbers) 素数筛法+暴力 Java
- 关于集合hashtable,hashmap,hashset,treemap,treeset的几点简单
- [AHOI2006]文本编辑器editor (Splay tree)
- HTTP原理
- Java里的按值传递与引用传递
- 代码重构(转)
- poj 2739 Sum of Consecutive Prime Numbers (最大连续素数和)
- JDBC数据库连接池的实现及原理
- 下载的空格变成+, 括号变成乱码-------处理文件名包含%20 不转换成空格
- 序列化
- select、Poll、epoll比较
- poj2377
- 安装jeffy.txt
- poj 2136 Vertical Histogram (模拟)
- Done