zoukankan      html  css  js  c++  java
  • CodeForces 327B

    Description

    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 Input

    Input
    3
    Output
    2 9 15
    Input
    5
    Output
    11 14 20 27 31

     题意:给你一个n,

    你列出来n个数字,这n个数字从小到大,而且相互之间不能互余。

    当N足够大的时候,列举相邻的几个数,则他们相互之间没有可以互余的,而且是递增的。

     1 #include <cstring>
     2 #include <cstdio>
     3 #include <iostream>
     4 #include <algorithm>
     5 #include <cmath>
     6 #include <stack>
     7 #include <vector>
     8 #include <queue>
     9 #include <cmath>
    10 using namespace std;
    11 #define N 1050000
    12 int main()
    13 {
    14     int i,n;
    15     while(scanf("%d", &n) != EOF)
    16     {
    17         for(i=N-n+1;i<=N;i++)
    18         {
    19             if(i==N)
    20                 printf("%d
    ",i);
    21             else
    22                 printf("%d ",i);
    23         }
    24     }
    25 
    26     return 0;
    27 }
     
  • 相关阅读:
    css 网站
    python操作redis
    排名函数row_number(),rank(),
    行转列面试题
    hive建表failed: ParseException line 6:0 cannot recognize
    windows10系统安装
    between ...and...
    系统变量path误删之后的恢复方法
    python的第三方库
    1054, "Unknown column 'serviceDate' in 'where clause'
  • 原文地址:https://www.cnblogs.com/biu-biu-biu-/p/5777225.html
Copyright © 2011-2022 走看看