Prime Gap
来源:互联网 发布:macbook办公软件好用吗 编辑:程序博客网 时间:2024/05/17 22:09
http://poj.org/problem?id=3518
// File Name: poj3518.cpp// Author: bo_jwolf// Created Time: 2013年10月11日 星期五 15:46:48#include<vector>#include<list>#include<map>#include<set>#include<deque>#include<stack>#include<bitset>#include<algorithm>#include<functional>#include<numeric>#include<utility>#include<sstream>#include<iostream>#include<iomanip>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<ctime>using namespace std;const int maxn = 1399709;vector< int > prime;int unprime[ maxn ];void Union(){memset( unprime, 0, sizeof( unprime ) );unprime[ 0 ] = unprime[ 1 ] = true;for( int i = 2; i < maxn; ++i ){if( !unprime[ i ] ){prime.push_back( i );for( int j = i + i; j < maxn; j += i ){unprime[ j ] = true;}}}}int main(){Union();int n, l, r, mid;while( cin >> n ){if( !n )break;int ans = 0;l = 0;r = prime.size() - 1;for( int i = 0; i < prime.size(); ++i ){if( prime[ i ] < n && prime[ i + 1 ] > n ){ans = prime[ i + 1 ] - prime[ i ];}}cout << ans << endl;}return 0;}
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- Prime Gap
- d613: Prime Gap
- 1500 Prime Gap
- poj 3518 Prime Gap
- 1500. Prime Gap
- sicily--1500. Prime Gap
- poj 3518 Prime Gap
- PKU3518 Prime Gap
- POJ-3518-Prime Gap
- Sicily 1500. Prime Gap
- sicily 1500.Prime Gap
- poj 3518 Prime Gap
- error: expected ')' before '*' token
- MFC中调用软键盘
- Android中的回调函数Callback——highlight
- 用js测试浏览器的js代码
- ubuntu 实用快捷键
- Prime Gap
- viewDidUnload 和 dealloc 的区别
- linux建立服务器间互信
- Python机器学习库
- 独家专供:PHP的URL验证正则算法,有史以来最强悍的
- enum枚举类型赋值之switch语句与显示类型转换(Explicit Type Conversion)速度之比较
- 图片的下载
- RESTful架构
- 简介.NET是什么