POJ 3518
来源:互联网 发布:知乎俄罗斯航空发动机 编辑:程序博客网 时间:2024/06/10 13:09
#include<string.h>#include<cstdio>#include<cstdlib>#include<iostream>#include<vector> #include<set>#include<cmath>#include<algorithm>using namespace std;const int maxn=1299710;bool u[maxn];int ans[maxn];void prepare(){int i,j,k;for(i=2;i<maxn;i++)u[i]=1;for(i=2;i<maxn;i++)if(u[i])for(j=2;j*i<maxn;j++)u[i*j]=0;for(i=2;i<maxn;i++)if(!u[i]){j=i;while(j<maxn&&!u[j])j++;j--;for(k=i;k<=j;k++)ans[k]=j-i+2;i=j;}else ans[i]=0;}int main(){int i,j,k;prepare();while(scanf("%d",&k)>0&&k){printf("%d\n",ans[k]);}}
阅读全文
0 0
- POJ 3518
- POJ 3518
- POJ 3518
- POJ 3518
- poj 3518 Prime Gap
- poj 3518 Prime Gap
- POJ-3518-Prime Gap
- poj 3518 Prime Gap
- poj 3518(二分)
- POJ 3518 Prime Gap
- poj 3518 prime jap
- POJ - 3518 Prime Gap
- POJ 【3518】 Prime Gap
- poj 3518 Prime Gap
- POJ 3518 Prime Gap
- POJ 3518 Prime Gap
- POJ 3518 Prime Gap
- POJ
- SQL中的case when then else end用法
- C语言学习总结
- 删除Git提交记录
- HDU 5917:Ramsey定理
- 什么是面向对象对象,什么是面向过程,什么是面向对象思想。
- POJ 3518
- 深夜切题——PKKJ的生日礼物
- Java基础-为什么要抽象?
- Python入门记——模块的命名空间
- 安卓真机测试
- centos 6.9配置IP
- java极光短信的集成
- poj2528 线段树+离散化
- 2x+xy+x/y=243求正整数解代码