B - Terse princess

B - Terse princess

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

很巧妙地一个模拟题, 用二进制来构造的,分为三种情况.
1 WOW 二进制思维处理Wow的情况
2 Oh
3 最后一般
PS:
1.b=0且普通情况只有一个时不能构造;
2.第一个数是普通情况;
3.Wow,Oh条件都满足时为Wow情况。

#include<stdio.h>
int t[106];
int main()
{
    int n, a, b, i;
    scanf("%d %d %d",&n,&a,&b);
    if(!b && a && n - a == 1)
    {
        printf("-1\n");
        return 0;
    }
    printf("1");
    t[0] = 1;
    for(i = 1; i < n; i++)
    {
        if(!b && i == 1)
        {
            t[1] = 1;
            printf(" 1");
            a++;
            continue;
        }
        if(i <= b)
            t[i] = 1 << i;
        else if(i <= a + b)
            t[i] = t[i-1] + 1;
        else
            t[i] = t[i-1];
        printf(" %d",t[i]);
    }
    printf("\n");
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值