poj 2739 Sum of Consecutive Prime Numbers
来源:互联网 发布:广州用友软件代理商 编辑:程序博客网 时间:2024/06/16 13:28
题目大意:
给你一个数,让你判断有几组连续的素数之和与其相等。
此题比较水。。。
#include<stdio.h>#include<string.h>bool f[10000];//标记数组int a[5000];int cont;void ss(){ int i,j; cont=0; memset(f,true,sizeof(f)); for(i=2;i<10000;i++)//筛选素数 { if(f[i])//标记,用于判断是否为素数 { a[cont++]=i; for(j=i*i;j<10000;j+=i) { f[j]=false; } } }}int main(){ int i,n,count,t,s; ss(); while(~scanf("%d",&n)) { if(n==0) break; if(n==1)//对特殊情况1进行处理 { printf("0\n"); continue; } count=0; for(i=0;i<cont;i++) { t=i; s=0; while(s<n) { s=s+a[t]; t++; } if(s==n) count++;//记录相等的组数 } printf("%d\n",count); } return 0;}
0 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
- 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
- ACM 73. 找最佳通路(水广搜)
- 【PHP学习笔记】正则表达式-----------2014.8.16下午
- 《END-TO-END ARGUMENTS IN SYSTEM DESIGN》 阅读报告
- 深入理解C++面向对象机制(三)构造与析构
- 写存储过程时候 type cur is ref cursor 这句话是什么意思
- poj 2739 Sum of Consecutive Prime Numbers
- c语言删除字符串中的数字字符
- 企业会计准则(具体准则)第4号——固定资产
- 2014-8-16 Android listview 错位
- ETL处理过程介绍
- js的正则
- JSP导出Excel表格 文件名+内容乱码解决+网格显示
- ACM 75. [NOIP2004] 合并果子(水贪心)
- c语言给定一个英文句子,单词间用1个空格隔开,求单词个数