B. 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 a1a2, ..., 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
//我火星了,其实从100000,开始输出就可以了,但我。。。唉
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 1000000
int a[N+1]={0},p[N]={2,3};
int main(){
int n,m=2,i,j,k=4;
int x,y;
for(i=5;i<N;i+=k^=6){
if(a[i]==0){
p[m++]=i;
for(j=i;j<=N/i;j++)a[j*i]=-1;
}
}
//for(i=0;i<100;i++)cout<<p[i]<<" ";
//cout<<m<<endl;
while(~scanf("%d",&n)){
if(n<=m){
printf("%d",p[0]);
for(i=1;i<n;i++)printf(" %d",p[i]);printf("\n");
}else{
printf("10");//5,7,11,....
for(i=j=4,x=14,y=15;--n;){
if(x>y){
printf(" %d",y);
y=p[j++]*3;
}else{
printf(" %d",x);
x=p[i++]*2;
}
}
printf("\n");
}
}
return 0;
}

CF 327B. Hungry Sequence的更多相关文章

  1. cf B. Hungry Sequence

    http://codeforces.com/contest/327/problem/B 这道题素数打表就行. #include <cstdio> #include <cstring& ...

  2. Codeforces Round #191 (Div. 2) B. Hungry Sequence(素数筛选法)

    . Hungry Sequence time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. codeforces 327 B. Hungry Sequence

    题目链接 题目就是让你输出n个数的序列,要保证该序列是递增的,并且第i个数的前面不能保护它的约数,我直接先对前100000的素数打表,然后输出前n个,so easy. //cf 191 B #incl ...

  4. 【CF 1059C】 Sequence Transformation 数学

    C. Sequence Transformation:http://codeforces.com/contest/1059/problem/C 题意 给你一个n,第一次输出1-n个数的gcd,然后你可 ...

  5. cf 11A Increasing Sequence(水,)

    题意: A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i <  ...

  6. codeforces hungry sequence 水题

    题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...

  7. cf 1241 D. Sequence Sorting(思维)

    题意: 一个序列有n个数,有一种操作,你可以选一个数x,使这个序列中等于x的数都移到序列头或尾. 问最少几次操作后,可以使这个序列非降序. 思路: (以下说bi移动到哪里,其实就是指a1……an中等于 ...

  8. 2013/7/16 HNU_训练赛4

    CF328B Sheldon and Ice Pieces 题意:给定一个数字序列,问后面的数字元素能够组成最多的组数. 分析:把2和5,6和9看作是一个元素,然后求出一个最小的组数就可以了. #in ...

  9. CodeForces 327B 水题。

    I - 9 Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

随机推荐

  1. 解决命令行运行python文件,出现No module named *** 报错问题

    有时候在一个项目中运行的时候,可能是之前已经mark成sources root 你自己忘记了, 于是就在命令行也执行python文件,然后就出现 No module named *** 等 相关你认为 ...

  2. Python 中的函数

    学了 Python 中的数据类型,语句,接下来就来说一下 Python 中的函数,函数是结构化编程的核心.我们使用函数可以增加程序的可读性.自定义函数时使用关键字def 函数由多条语句组成.在定义函数 ...

  3. <泛> STL - stack 模拟实现

    今天,看C++Template的时候看到那人写了一个Stack,于是乎,手痒,自己也写了一个,在拜读了STD文件和C++模板元编程某些小节之后,你们就看到了这篇代码. 经过上述一番经历之后,我重新写了 ...

  4. HTTP/FTP压力测试工具siege

    HTTP/FTP压力测试工具siege   压力测试可以检测服务器的承载能力.针对HTTP和FTP服务,Kali Linux提供专项工具siege.该工具可以模拟多个用户同时访问同一个网站的多个网页, ...

  5. Revit二次开发示例:DeleteObject

    在本例中,通过命令可以删除选中的元素. 需要注意的是要在代码中加入Transaction,否则的话会出现Modifying  is forbidden because the document has ...

  6. .NET Core改造工程直播

    [背景] 新项目需要跨平台,原来积累的.NET类库需要改造为.NET Core. [直播] 新增加的项目不支持排除文件 不支持定义条件编译常量,虽然在项目中能使用#if语法,但无地方定义DefineC ...

  7. [ 原创 ]linux centos下配置java环境教程

    一.环境 centos 7.2 二.目标 在CentOS7.2上安装jdk1.8(tar.gz安装包),并配置环境变量 jdk安装在/home/soft/jdk1.8.0-131目录下 具体步骤 1. ...

  8. BZOJ 2333: [SCOI2011]棘手的操作 可并堆 左偏树 set

    https://www.lydsy.com/JudgeOnline/problem.php?id=2333 需要两个结构分别维护每个连通块的最大值和所有连通块最大值中的最大值,可以用两个可并堆实现,也 ...

  9. Codeforces Round #489 (Div. 2)

    A. Nastya and an Array time limit per test 1 second memory limit per test 256 megabytes input standa ...

  10. 王彪-20162321《程序设计与数据结构2nd》-第十一周学习总结与实验报告

    邻接矩阵实现 例图 分析 变量 需要一个链表来保存数据-即保存结点 需要一个二维数组来保存每个变得权值,有则填入具体数值,没有则用0 定义一个保存边个数的值 函数方法 得到图中边的个数 得到结点的数据 ...