链接:戳这里
C. Terse princess
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
题意:
公主看新郎,当前看到的第i个新郎的价值如果比之前所有的新郎加起来的总价值还大。“wow”
当前看到的第i个新郎的价值比之前看到的所有新郎都大。“oh”
给出叫的次数以及新郎的总人数。输出任意满足条件的序列
思路:
先构造"wow"的,一直往后*2就行了 ,然后再填“oh”往后+1就可以了
tick点是a为0的时候或者b为0的时候。
这里说个b为0的吧。a2>a1就一定会使得“wow”的次数>=1。所以注意这里
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
int anw[110];
int main(){
/// cout<<(1<<16)<<endl;
anw[0]=1;
int n,a,b;
scanf("%d%d%d",&n,&a,&b);
if(b==0){
if(a && a>=n-1){
cout<<-1<<endl;
return 0;
}
anw[1]=1;
int i;
for(i=2;i<=a+1;i++) anw[i]=anw[i-1]+1;
for(;i<n;i++) anw[i]=1;
for(int i=0;i<n;i++) cout<<anw[i]<<" ";cout<<endl;
return 0;
}
int i;
for(i=1;i<=b;i++) anw[i]=anw[i-1]*2;
if(anw[i]>50000) {
cout<<-1<<endl;
return 0;
}
for(;i<=b+a;i++) anw[i]=anw[i-1]+1;
for(;i<n;i++) anw[i]=1;
for(int i=0;i<n;i++) cout<<anw[i]<<" ";cout<<endl;
return 0;
}