CodeForces - 148C C - Terse princess 构造数列

来源:互联网 发布:centos mv 移动目录 编辑:程序博客网 时间:2024/05/07 16:36

«Next please», — the princess called and cast an estimating glance at the next groom.

The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured «Oh...». Whenever the groom is richer than all previous ones added together, she exclaims «Wow!» (no «Oh...» in this case). At the sight of the first groom the princess stays calm and says nothing.

The fortune of each groom is described with an integer between 1 and 50000. You know that during the day the princess saw n grooms, said «Oh...» exactly a times and exclaimed «Wow!» exactly b times. Your task is to output a sequence of n integers t1, t2, ..., tn, where tidescribes the fortune of i-th groom. If several sequences are possible, output any of them. If no sequence exists that would satisfy all the requirements, output a single number -1.

Input

The only line of input data contains three integer numbers n, a and b(1 ≤ n ≤ 100, 0 ≤ a, b ≤ 15, n > a + b), separated with single spaces.

Output

Output any sequence of integers t1, t2, ..., tn, where ti (1 ≤ ti ≤ 50000) is the fortune of i-th groom, that satisfies the given constraints. If no sequence exists that would satisfy all the requirements, output a single number -1.

Example
Input
10 2 3
Output
5 1 3 6 16 35 46 4 200 99
Input
5 0 0
Output
10 10 6 6 5
Note

Let's have a closer look at the answer for the first sample test.

  • The princess said «Oh...» (highlighted in bold): 5 1 3 6 16 3546 4 200 99.
  • The princess exclaimed «Wow!» (highlighted in bold): 5 1 3 6 1635 46 4 200 99.


题意:

公主辨别宝物,如果当前宝物价值大于所有之前宝物价值总和就会说wow ,如果大于之前任何一个宝物价值就会说oh, 

现在有a个oh b个wow 询问宝物出现价值顺序     这里注意说wow就不会算在oh中

思路:

只要是让我们输出一个序列的都应该先想想构造啊.....为了使最大的尽可能的小,所以要先构造wow ,之后构造oh

我这里的构造是按照2的n次方来构造的,因为其保证后一项会大于前面所有的和;剩下的全部构造为1即可,

题目有几个坑点:

  首先我们来说一下什么情况下无法构造序列,当b=0时,并且a!=0并且  n-a==1,因为这里无论怎么构造第二个数都会比第一个大优先wow

  其次当n==1时我们也是可以的 输出  1即可

  还有当  b==0时  由于我们不能构造出 某项比前面所有和都大的情况,这里需要注意





#include<bits/stdc++.h>
using namespace std;
int t[500];
int a,b,n,x,i;
int main()
{   cin>>n>>a>>b;
    if(!b&&a&&n-a==1)
    {  printf("-1");
       return 0;
    }
    printf("1");
    t[0]=1;
    x=2;
    for(i=1;i<n;i++)
    {   
   if(b==0&&i==1)
   {    t[i]=1;
        a++;
   }
   else if(i<=b)
         {  t[i]=x;
            x*=2;
         }
         else if(i<=a+b)
         {   t[i]=t[i-1]+1;
         }
         else
         t[i]=1;
    }
    for(i=1;i<n;i++)
    cout<<' '<<t[i];
    return 0;
}


1 0