Codeforces-148C-standard output(構造)

C. Terse princess
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

«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 ti describes 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.

Examples
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 35 46 4 200 99.
  • The princess exclaimed «Wow!» (highlighted in bold): 5 1 3 6 16 35 46 4 200 99.

題意:構造一個序列,有a個比前面的數都大的數,有b個比前面所有的數的和都大的數

思路:要構造這樣的序列,可以選擇先確定那b個數,記錄前綴和,然後確定a個數,比之前最大的數大一就ok,然後剩下的數全部爲1,然後注意一些細節,具體請看代碼

AC代碼:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b;
int ans[150];
int main()
{
    while(~scanf("%d%d%d",&n,&a,&b))
    {
        if((a+b)==0){//直接倒序輸出
            for(int i=n;i>=1;i--)
                printf("%d%c",i,i==1?'\n':' ');
            continue;
        }
        if(a==n-1){//a最多爲n-2,思考一下。。
            printf("-1\n");
            continue;
        }
        else if(n==2&&b==1){
            printf("1 2\n");
            continue;
        }
        if(b>=1){//根據b的不同確定開頭兩個數
            ans[1]=1;
            ans[2]=2;
            b--;
        }
        else{
            ans[1]=2;
            ans[2]=1;
        }
        int tmp=3;
        int p=3;
        for(;b>0;p++)
        {
            ans[p]=tmp+1;
            b--;
            if(b)tmp+=ans[p];//b>0時tmp爲前綴和
            else tmp+=2;//b=0之後+2,比前一個數大一就好

        }
        for(;a>0;p++)
        {
            ans[p]=tmp;//a大於0時,每次只要比前面的數大一個就行
            tmp++;
            a--;
        }
        for(;p<=n;p++)//剩下的都爲1
            ans[p]=1;
        for(int i=1;i<=n;i++)
            printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章