. 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. Python:生成器的简单理解

    一.什么是生成器 在Python中,由于受到内存的限制,列表容量肯定是有限的.例如我们创建一个包含一亿个元素的列表,Python首先会在内存中开辟足够的空间来存储这个包含一亿个元素的列表,然后才允许用 ...

  2. 用P4对数据平面进行编程

    引言 SDN架构强调了对控制平面的可编程,数据平面只负责转发,导致数据平面很大程度上受制于功能固定的包处理硬件. P4语言的特性: 目标无关性:P4语言不受制于具体设备,所有可编程芯片都可以使用P4编 ...

  3. QMultiMap使用

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:QMultiMap使用     本文地址:http://techieliang.com/201 ...

  4. 【final】Scrum站立会议第2次....11.20

    小组名称:nice! 组长:李权 成员:于淼  刘芳芳韩媛媛 宫丽君 项目内容:约跑app(约吧) 时间:2016.11.9    12:00——12:30 地点:传媒西楼220室 本次对fnal阶段 ...

  5. 使用 TestNG 并发测试 ;

    使用TestNG对IE /Chrome/firefox 进行兼容性并发测试 : package testNGTest; import org.openqa.selenium.By; import or ...

  6. 用iptables做代理

    出于安全考虑,Linux系统默认是禁止数据包转发的.配置Linux系统的ip转发功能,打开系统转发功能:echo "1" > /proc/sys/net/ipv4/ip_fo ...

  7. 使用fabric1.14.0和fabric2.4.0

    fabric1.14.0(支持Python2.5-2.7版本): from  fabric.api import * env.gateway = '192.168.181.2'            ...

  8. 【前端学习笔记05】JavaScript数据存储Cookie相关方法封装

    //Cookie设置 //设置新cookie function setCookie(name,value,duration){ var date = new Date(); date.setTime( ...

  9. appium使用H5怎么定位元素

    允许是一个class,如果遇到有多个class,只能填写一个. 对于移动端H5元素定位采用Chromedriver的解决方案,具体操作如下: 1.手机安装Chrome浏览器 2.开启USB调试模式,并 ...

  10. 洛谷 P2421 A-B数对(增强版)

    题目描述 给出N 个从小到大排好序的整数,一个差值C,要求在这N个整数中找两个数A 和B,使得A-B=C,问这样的方案有多少种? 例如:N=5,C=2,5 个整数是:2 2 4 8 10.答案是3.具 ...