UVa1644 - Prime Gap
来源:互联网 发布:linux shell脚本减法 编辑:程序博客网 时间:2024/06/04 18:39
#include<iostream>using namespace std;const unsigned maxn = 1300010;int p[maxn], n;bool np[maxn] = {true, true};int main(){ ios::sync_with_stdio(false); for(int i=2; i<maxn; i++){ if(!np[i]) p[n++]=i; for(int j=0;j<n&&i*p[j]<maxn;j++){ np[i*p[j]]=1; if(!(i%p[j])) break; } } while(cin>>n&&n){ if(!np[n]){ cout<<"0"<<endl; continue; } int i=n,j=n; while(np[i]) i--; while(np[j]) j++; cout<<j-i<<endl; } return 0;}素数怎么求的,明天再看看
0 0
- UVa1644 Prime Gap
- UVA1644 - Prime Gap
- UVa1644 - Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- uva1644
- d613: Prime Gap
- 1500 Prime Gap
- poj 3518 Prime Gap
- 1500. Prime Gap
- sicily--1500. Prime Gap
- poj 3518 Prime Gap
- PKU3518 Prime Gap
- C++中构造函数、析构函数以及类成员初始化顺序详解
- Variance
- mybatis:"configuration" must match "(properties?,settings?,typeAliase.....
- 腾讯笔试题精选一
- chmod
- UVa1644 - Prime Gap
- (产品技术)Axure7.0圆角矩形
- android一个BaseAdapter的使用(LayoutInflater加载自定义布局)
- xcode6.2 新建分类方法
- DNA Sorting
- 第32天【健身】
- makefile:简单入门
- Java 开发环境创建和执行Java程序的典型步骤
- 安卓中缩放图片到imageview(imageview出现OutOfMemoryError)