CF 饥饿序列

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的序列Ai。

已知:(1 ≤ n ≤ 105),并且 a1 a2, ..., an (1 ≤ ai ≤ 107)

序列满足以下两个条件:

1.序列中满足严格意义上的递增,即任意一对相邻的数都是后者比前者大。

2.后面任意的一个数都不能被前面任意一个数整除。

那么,如果你用模拟,肯定超时。

想想,当序列Ai从10^6开始时,n最多是10^5,相加也不会超过10^7,;而且,10^6 ~ 10^7之间的任意两个数,较大的数都不能被较小的数整除,因为较大的数连较小的数的2倍都无法满足。所以在10^6 ~ 10^7之间的数是永远满足条件2的,现在只需完成条件1即可。

核心代码只有一个for循环和判断条件的printf。

代码如下:

#include <stdio.h>
#define N 100000
#define MAX 1000000
int main()
{
    int n,m,i,t;
    while(scanf("%d",&n)!=EOF)
 {
        m = MAX + n;
        t = 1;
        for(i=MAX; i<m; i++)
  {
            if(t!=n)
   {
                printf("%d ",i);
                t++;
            }
            else printf("%d\n",i);
        }
    }
    return 0;
}
View Code

 

posted on 2013-07-10 01:01  Forgiving  阅读(154)  评论(0编辑  收藏  举报