uva1644
来源:互联网 发布:淘宝店是怎么打广告的 编辑:程序博客网 时间:2024/06/06 03:17
/**********author:chanjun2016email:15755396353@163.com***********/#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <vector>#include <string>#include <map>#include <set>#include <algorithm>using namespace std;#define INF = 0x3f3f3f3fconst int maxn = 13e5;int vis[maxn + 10];set<int> S;void init(){int q = sqrt(maxn + 0.5);for (int i = 2;i <= q; ++i){if (!vis[i]){for (int j = i * i; j <= maxn; j += i){vis[j] = 1;}}}for (int i = 2;i <= maxn; ++i){if (!vis[i]){S.insert(i);}}}int main(){int n;init();while (scanf("%d",&n),n > 0){auto begin = lower_bound(S.begin(),S.end(),n);if (*begin == n){printf("0\n");}else{auto end = *begin;printf("%d\n", end - *--begin);} }return 0;}
0 0
- uva1644
- UVa1644 Prime Gap
- UVA1644 - Prime Gap
- UVa1644 - Prime Gap
- 习题10-4 素数间隔 UVa1644
- android适配
- 测试常用公式
- 【转载】职业规划很全面的一篇文章
- 计算机中的数与数据
- android4.0手机访问某些网页提示证书过期或者证书不符的处理办法
- uva1644
- 判断素数
- python toy codes
- FatMouse' Trade
- freearker相当中的一节指令macro也是自定义函数指令
- SQL Linked Servers创建语句
- CBCentralManager 蓝牙透传
- redis 集群安装配置
- 单件模式基类