CodeForces 148C - Terse princess
来源:互联网 发布:java ssh项目 编辑:程序博客网 时间:2024/04/26 23:04
«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.
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 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.
10 2 3
5 1 3 6 16 35 46 4 200 99
5 0 0
10 10 6 6 5
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.
==================================
这题坑很多……WA了几次看了数据才改过来……主要就是-1出现的条件
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int a[111111];int main(){ int n,a,b,s[111]={0}; cin>>n>>a>>b; if(n-a==1&&!b&&a) { cout<<"-1"<<endl; return 0; } s[0]=1; int sum=1; int i; for(i=1;i<=b;i++) { s[i]=sum+1; sum+=s[i]; } if(b==0) { s[1]=1; i++; b=1; } for(;i<=a+b;i++) { s[i]=s[i-1]+1; } for(;i<=n;i++) { s[i]=1; } for(int i=0;i<n;i++) cout<<s[i]<<" "; cout<<endl; return 0;}
- CodeForces 148C - Terse princess
- CodeForces 148C-Terse princess
- codeforces-148C-Terse princess【构造】
- CodeForces - 148C C - Terse princess 构造数列
- Codeforces Round #105 (Div. 2) 148C Terse princess(脑洞)
- codeforces 148C Terse princess(有意思的模拟)
- C. Terse princess
- Codeforces Round #105 (Div. 2) C. Terse princess
- CodeForces 148CTerse princess(模拟)
- CodeForces 148CTerse princess(这个题也是个坑...)
- codeforces 148 div2 C
- codeforces 148c
- Codeforces-148C-standard output(构造)
- Codeforces-340-C(c++)
- Codeforces-507-C(c++)
- CodeForces 731C C
- CodeForces-612C C
- c语言杭电1029Ignatius and the Princess IV
- ios6.x 插件介绍及常用源
- python学习教程(七)sqlalchemy框架的配置
- IT人员看待和预防癌症十大建议
- 结构体对齐详解
- Delphi压缩流和解压流的应用
- CodeForces 148C - Terse princess
- WCF Windows集成身份验证详细步骤。
- Java实现CSV读写操作源代码
- C++之tinyXML使用
- ArcEngine加载TIN数据
- 文件复制示例
- 网上找的google地图的级别和比例尺、分辨率之间的关系
- tinyxml使用笔记与总结
- delphi中ShellExecute使用详解