您的位置:首页 > 其它

codeforces 148C Terse princess(有意思的模拟)

2017-12-05 22:34 866 查看
«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.

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

题解:

我的思路是从1开始,先模拟wow的情况,也就是a[i]=s+1,再模拟oh的情况,a[i]=a[i-1]+1,如果循环完还剩就-1,然后wa了一发看了数据19 1 0这种我输出是-1,但是是有答案的,就只要当wow的个数放完后放oh的时候特判当前前面的和s是否大于将要放进去的a[i]=a[i-1]+1,如果大了就慢点放,用a[i]=a[i-1]先将s撑大一些再放,如果循环完num1和num2有剩余,就输出-1

代码:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<stdio.h>
using namespace std;
#define ll long long
int a[105];
int main()
{
int num1,num2,i,j,s=1,n;
scanf("%d%d%d",&n,&num1,&num2);
a[0]=1;
for(i=1;i<n;i++)
{
if(num2)
{
a[i]=s+1;
num2--;
}
else if(num1)
{
a[i]=a[i-1]+1;
if(s<a[i])
{
a[i]=a[i-1];
}
else
num1--;
}
else
a[i]=a[i-1];
s+=a[i];
}
if(num1||num2)
printf("-1\n");
else
{
printf("%d",a[0]);
for(i=1;i<n;i++)
printf(" %d",a[i]);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: