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. linux用户下的.profile文件丢失

    登录用户时出现以下问题: #su - wqq-bash-4.1$ -bash-4.1$ 查看时发现环境变量文件丢失造成的 解决方法: # ls -la /etc/skel/  total 36drwx ...

  2. Bootstrap入门九:辅助类

    1.情境文本颜色 通过颜色来展示意图,Bootstrap 提供了一组工具类.这些类可以应用于链接,并且在鼠标经过时颜色可以还可以加深,就像默认的链接一样. <p class="text ...

  3. openwrt安装tcpdump

    打开openwrt路由器的ssh功能 System->administration Ssh登陆 opkg update 会报很多错误 措施如下: 备份 /etc/opkg.conf Cp /et ...

  4. 洛谷——P1231 教辅的组成

    P1231 教辅的组成 题目背景 滚粗了的HansBug在收拾旧语文书,然而他发现了什么奇妙的东西. 题目描述 蒟蒻HansBug在一本语文书里面发现了一本答案,然而他却明明记得这书应该还包含一份练习 ...

  5. HTML基础-DAY1

    HTML基础 Web的本质就是利用浏览器访问socket服务端,socket服务端收到请求回复数据提供给浏览器进行渲染显示. import socket def main(): sock = sock ...

  6. 深入理解ajax系列第九篇

    前面的话 jQuery提供了一些日常开发中需要的快捷操作,例如load.ajax.get和post等,使用jQuery开发ajax将变得极其简单.这样开发人员就可以将程序开发集中在业务和用户体验上,而 ...

  7. leetcode 链表 两数相加

     两数相加     给定两个非空链表来表示两个非负整数.位数按照逆序方式存储,它们的每个节点只存储单个数字.将两数相加返回一个新的链表. 你可以假设除了数字 0 之外,这两个数字都不会以零开头. 示例 ...

  8. es6新增功能

    声明命令 1. let命令 ES6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效.下面代码在代码块之中,分别用let和var声明了两个变量.然 ...

  9. android manifest.xml 文件

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 清单文件 包括 包名 应用 各个组件  四大组件 使用到的权限 应用程序所需要的最低安卓 ...

  10. Codeforces Round #463

    A - Palindromic Supersequence /* 题目大意:给出一个串,构造一个包含该串的回文串 */ #include <cstdio> #include <alg ...