题目链接:http://codeforces.com/problemset/problem/148/C点击打开链接

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

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.

题目要求小于50000

2^15==30000+ 因此不会超 但是正是因为这个临界 坑点很多

我们可以这样想 因为最大不会超 因此可以1 2 4 。。吧b的个数造出来

再造a 每次+1

但是因为唯一特殊的2-1=1&&2》sum(1)

因此要判断特殊条件

给几个特例

1 0 0

2 1 0

3 1 0

其中1 0 0 可以构造

但如果存在b=0并且n=a-1 如2 1 0 则不存在 因为必定存在前两个数 第二个数即大于第一个数 又比他总和大

然后如果是b=0且n!=a-1时 则需要先把剩余数输出 使得不会出现前两位的重叠情况

#include <bits/stdc++.h>
using namespace std;
int a[111111];  int main()
{  int n,a,b;cin>>n>>a>>b;  if(n==a+1){    if(a!=0){  cout << -1 << endl;return 0;}}if(b==0){int num=1;int cnt=n-a-b;b++;cnt--;while(cnt--){cout << "1" << " ";}while(b){cout << num << " ";b--;if(b)num<<=1;}while(a){cout << ++num << " ";a--;}return 0;}int num=1;int cnt=n-a-b;b++;cnt--;while(b){cout << num << " ";b--;if(b)num<<=1;}while(a){cout << ++num << " ";a--;}while(cnt--){cout << "1" << " ";}
}

CodeForces - 148C Terse princess (构造)相关推荐

  1. CodeForces 148C - Terse princess

    C. Terse princess time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  2. 【思维 构造】CodeForces - 148C Terse princess

    Problem Description 让你写出一个序列,满足长度是n,里面含有a个«Oh-» b个«Wow!» ..«Wow!» 代表你加进去的这个数比前面所有数的和都大.«Oh-» 代表你加进去的 ...

  3. CodeForces 148C Terse princess(模拟)

    太坑了...这题 #include<iostream> #include<cstdio> #include<algorithm> #include<cstdl ...

  4. codeforces 148 C. Terse princess(思维,构造)

    C. Terse princess(思维,构造) 题目链接:codeforces 148C 题意:     有个公主找王子,如果这个人比之前所有王子的财富都高,公主就会Oh,              ...

  5. CodeForces - 287C Lucky Permutation(构造)

    题目链接:点击查看 题目大意:构造一个合法的排列,满足 ppi=n−i+1p_{p_{i}}=n-i+1ppi​​=n−i+1 题目分析:因为第四个样例的存在降低了本题的难度,不然感觉还是有点难度的一 ...

  6. CodeForces - 468C Hack it!(构造+数位dp)

    题目链接:点击查看 题目大意:求出一段区间 [l,r][l,r][l,r] 的数位和对 aaa 取模后为 000.更具体的,设 f(x)f(x)f(x) 为 xxx 的数位和,本题需要求出一对 [l, ...

  7. CodeForces - 1561E Bottom-Tier Reversals(构造)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的排列,每次操作可以选择一个奇数长度的前缀然后反转,需要构造一种方案,使得在不超过 5n2\frac{5n}{2}25n​ 次操作后使得序列有序 ...

  8. CodeForces - 1494E A-Z Graph(构造+思维)

    题目链接:https://vjudge.net/problem/CodeForces-1494E 题目大意:给出一个初始时只有 nnn 个点的有向带权图,需要执行 mmm 次操作,每次操作分为下列三种 ...

  9. CodeForces - 1494D Dogeforces(贪心+构造)

    题目链接:点击查看 题目大意:给出 nnn 个叶子结点和一个 n∗nn*nn∗n 的 LCALCALCA 矩阵,其中 LCALCALCA 表示的是最近公共祖先节点的权值,现在需要构造出一棵自顶向下权值 ...

最新文章

  1. 【学习笔记】opencv的python接口 几何变换
  2. CodeForces - 1579G Minimal Coverage(dp)
  3. UIViewController详解
  4. tp中怎么执行mysql事务_tp中使用事务
  5. 【TypeScript系列教程12】Number对象的基本使用
  6. python读hadoop_python读取hdfs并返回dataframe教程
  7. ios 调用webservice 辅助类
  8. ubuntu 的使用(五)—— 桌面(desktop)
  9. matlab数字图像处理大作业_线上教学优秀案例(16) | 数字图像处理基于蓝墨云+企业微信的线上教学经验分享...
  10. 机器人轨迹规划:三次样条曲线
  11. Python关于节假日的一些处理
  12. Unity 之 获取物体的旋转角正确数值
  13. h264, h265 和 libvpx 比较(h264/avc, hevc 和vp9比较)
  14. Mac 使用 Aria2 下载百度网盘资源
  15. Python修改证件照底色,get新技能
  16. Hi3516A开发--板卡烧写
  17. App don't display in google paly
  18. 微信小程序 -- 数据库数据excel文件批量导入
  19. sql 语句 将查询结果中数字等标示转成汉字
  20. 二分法算一元三次方程

热门文章

  1. 安信可ESP32 LVGL_V8 最快移植攻略
  2. Android usb网络共享开关
  3. Oracle --1536错误解决(超出表空间)
  4. (八)理解跨界思维(85)
  5. 现代数据中心对UPS系统的要求
  6. 不要钱的数据恢复软件?
  7. 内网安全学习(二)---横向渗透
  8. 基于asp.net医院药品进销存系统
  9. 助力企业加快攻破数字化“壁垒”,得帆信息的PaaS“组合拳”
  10. 使用autoindex标签给DEDECMS文章列表添加自动编号