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

 

转载于:https://www.cnblogs.com/LOB104-zhanglei/articles/3181180.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值