. 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. A10

    今日内容: 完善界面.解决剩下的一些问题 明日计划: 无 困难: 无

  2. 模拟jq的设置样式

    //需求,创建一个div,添加到页面上,给div添加属性 //面向对象开发,构造函数创建类 function divTag(){ this.div1=document.createElement('d ...

  3. jdbc 2.0

    1.Statement接口不能接受参数 2.PreparedStatement接口在运行时接受输入参数 3.CallableStatement接口也可以接受运行时输入参数,当想要访问数据库存储过程时使 ...

  4. 简易四则运算生成程序——添加GUI支持

    项目成员:张金生     张政 工程地址: https://coding.net/u/jx8zjs/p/paperOne/git ssh://git@git.coding.net:jx8zjs/pap ...

  5. gearman参数说明

    -b, –backlog=BACKLOG 连接请求队列的最大值 -d, –daemon Daemon 守护进程化 -f, –file-descriptors=FDS 可打开的文件描述符数量 -h, – ...

  6. delphi使用SQL的教程4(使用Params属性为参数赋值 )

    17.4.1 使用Params属性为参数赋值   TQuery部件具有一个Params属性,它们在设计时不可用,在程序运行过程中可用,并且是动态建立的,当为TQuery部件编写动态SQL 语句时, D ...

  7. dbgrid多选日记

    procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char); begin then begin DBGrid1.DataSourc ...

  8. HDU4474_Yet Another Multiple Problem

    题意很简单,要你用一些数字,组成一个数的倍数,且那个数最小. 比赛的时候没能做出来,深坑啊. 其实我只想说我以前就做过这种类型的题目了,诶. 题目的解法是数位宽搜. 首先把可用的数位提取出来,从小到大 ...

  9. C++解析(9):关于const和引用的疑问

    0.目录 1.关于const的疑问 2.关于引用的疑问 2.1 引用与指针 2.2 从C++语言与C++编译器角度看引用 2.3 从工程项目开发看引用 3.小结 1.关于const的疑问 const什 ...

  10. java垃圾回收 - 为什么要进行垃圾回收

    1.为什么要进行垃圾回收:      在C++中,对象所占的内存在程序结束运行之前一直被占用,在明确释放之前不能分配给其它对象:而在Java中,当没有对象引用指向原先分配给某个对象 的内存时,该内存便 ...