. Hungry Sequence

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Iahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of n integers.

A sequence a1, a2, ..., an, consisting of n integers, is Hungry if and only if:

  • Its elements are in increasing order. That is an inequality ai < aj holds for any two indices i, j (i < j).
  • For any two indices i and j (i < j), aj must not be divisible by ai.

Iahub is in trouble, so he asks you for help. Find a Hungry sequence with n elements.

Input

The input contains a single integer: n (1 ≤ n ≤ 105).

Output

Output a line that contains n space-separated integers a1 a2, ..., an (1 ≤ ai ≤ 107), representing a possible Hungry sequence. Note, that each ai must not be greater than 10000000 (107) and less than 1.

If there are multiple solutions you can output any one.

Sample test(s)
Input
3
Output
2 9 15
Input
5
Output
11 14 20 27 31

输出n个从小到大排列、每个数不超过范围的素数即可

AC Code:
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int maxn = ;
bool prime[maxn]; int main()
{
int n;
memset(prime, false, sizeof(prime));
for(int i = ; i * i < maxn; i++)
{
for(int j = ; i * j < maxn; j++)
prime[i*j] = true;
}
while(scanf("%d", &n) != EOF)
{
printf("");
for(int i = , j = ; i < n; j++)
{
if(prime[j] == false)
{
printf(" %d", j);
i++;
}
}
printf("\n");
}
return ;
}

Codeforces Round #191 (Div. 2) B. Hungry Sequence(素数筛选法)的更多相关文章

  1. 贪心 Codeforces Round #191 (Div. 2) A. Flipping Game

    题目传送门 /* 贪心:暴力贪心水水 */ #include <cstdio> #include <algorithm> #include <cstring> us ...

  2. Codeforces Round #191 (Div. 2)

    在div 188中,幸运的达成了这学期的一个目标:CF1800+,所以这次可以打星去做div2,有点爽. A.Flipping Game 直接枚举 B. Hungry Sequence 由于素数的分布 ...

  3. Codeforces Round #333 (Div. 1) B. Lipshitz Sequence 倍增 二分

    B. Lipshitz Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/601/ ...

  4. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  5. Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)

    链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...

  6. Codeforces Round #353 (Div. 2) A. Infinite Sequence

    Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its fi ...

  7. Codeforces Round #191 (Div. 2) D. Block Tower

    D. Block Tower time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  8. Codeforces Round #191 (Div. 2)---A. Flipping Game

    Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. codeforces水题100道 第二十题 Codeforces Round #191 (Div. 2) A. Flipping Game (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/327/A题意:你现在有n张牌,这些派一面是0,另一面是1.编号从1到n,你需要翻转[i,j]区间的 ...

随机推荐

  1. Alpha事后诸葛会议

    [设想和目标] Q1:我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? "小葵日记"是为了解决18-30岁年轻用户在记录生活时希望得到一美体验友好 ...

  2. jdbc 1.0

    1. jdbc : java数据库连接技术 2.主要用到的类及接口 Class Driver ManagerDriver Connection Statement PreparedStatement ...

  3. Kotlin在处理GET和POST请求的数据问题

    1.网络请求获取到的数据流处理 java写法 BufferedReader br = new BufferedReader(new InputStreamReader(in, "utf-8& ...

  4. dat.gui 上手

    dat.gui是款神器产品.一个调试利器.但是用起来很简单很简单 1:引用dat.gui.js. 2:实例化   this.gui = new dat.GUI(); 3:创建可设置一个数据对象.例如v ...

  5. pixi.js tools

    pixi群 881784250 Awesome pixi.js tools A list of useful libs/resources/tools for renowned html5 rende ...

  6. 剖析Vue原理&实现双向绑定MVVM-1

    本文能帮你做什么?1.了解vue的双向数据绑定原理以及核心代码模块2.缓解好奇心的同时了解如何实现双向绑定为了便于说明原理与实现,本文相关代码主要摘自vue源码, 并进行了简化改造,相对较简陋,并未考 ...

  7. 如何更好的使用JAVA线程池

    这篇文章结合Doug Lea大神在JDK1.5提供的JCU包,分别从线程池大小参数的设置.工作线程的创建.空闲线程的回收.阻塞队列的使用.任务拒绝策略.线程池Hook等方面来了解线程池的使用,其中涉及 ...

  8. SQL入门之多表查询

    如果查询需要针对两个或者更多个表,则在需要涉及到表的连接操作(join). 0.笛卡儿积 最简单的连接方式是直接在from子句中加入两个表,并且用join操作符隔开.形式为Table1 join Ta ...

  9. CF486D-Valid Sets

    题目 给出一个\(n\)个点的树,每个点有权值\(a_i\),再给出一个\(d\),问有多少个非空点集满足: 点集在树上构成联通子图 \[\max _{v\in S}a_v -\min _{v\in ...

  10. jmeter同步定时器

    同步定时器是jmeter中一个比较重要的定时器,同步定时器,相当于一个储蓄池,累积一定的请求,当在规定的时间内达到一定的线程数量,这些线程会在同一个时间点一起并发,可以用来做大数据量的并发请求. 验证 ...