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.

Sample test(s)
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.

题目链接:点击打开链接

有一个长度为n的序列, 假设一个数比前面的数都大, 则会说Oh, 假设一个数比前面全部数的和都大, 则会说Wow. 现给出Oh数a, Wow数

b, 要求输出一个满足题意的数组, 不存在这种数组则输出-1.

构造一个数组, a[1] = 1, 进行n - 2次操作, 每一次操作都记录当前值和前面数的和, 优先降低b, 为sum + 1, 否则降低a, 为res + 1.

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 105;
int n, a, b, ans[MAXN];
int main(int argc, char const *argv[])
{
scanf("%d%d%d", &n, &a, &b);
ans[1] = 1;
int res = 1, sum = 1;
for(int i = 2; i <= n; ++i) {
if(b) {
res = sum + 1;
b--;
}
else if(a && i > 2) {
res++;
a--;
}
ans[i] = res;
sum += res;
}
if(a || b) {
printf("-1\n");
return 0;
}
for(int i = 1; i < n; ++i)
printf("%d ", ans[i]);
printf("%d\n", ans[n]);
return 0;
}

Codeforces Round #105 (Div. 2) 148C Terse princess(脑洞)的更多相关文章

  1. 水题 Codeforces Round #105 (Div. 2) B. Escape

    题目传送门 /* 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 */ #include <cstdio> #include <alg ...

  2. Codeforces Round #105 (Div. 2) ABCDE

    A. Insomnia cure 哎 只能说英语太差,一眼题我看了三分钟. 题意:给5个数k, l, m, n 和 d,求1~d中能被k, l, m, n 至少一个整除的数的个数. 题解:…… 代码: ...

  3. Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp

    题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...

  4. Codeforces Round #105 (Div. 2) E. Porcelain —— DP(背包问题)

    题目链接:http://codeforces.com/problemset/problem/148/E E. Porcelain time limit per test 1 second memory ...

  5. codeforces水题100道 第四题 Codeforces Round #105 (Div. 2) A. Insomnia cure (math)

    题目链接:http://www.codeforces.com/problemset/problem/148/A题意:求1到d中有多少个数能被k,l,m,n中的至少一个数整出.C++代码: #inclu ...

  6. Codeforces Round #337 (Div. 2) 610C Harmony Analysis(脑洞)

    C. Harmony Analysis time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  8. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

  9. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

随机推荐

  1. SpringBoot学习笔记(16)----SpringBoot整合Swagger2

    Swagger 是一个规范和完整的框架,用于生成,描述,调用和可视化RESTful风格的web服务 http://swagger.io Springfox的前身是swagger-springmvc,是 ...

  2. textarea统计字数

    开发项目中经常会用到,textarea统计字数 源码如下: <!DOCTYPE html><html lang="en"><head> < ...

  3. [Debug]SpaceVim中neomake报错 Error while trying to load a compilation database

    回家装上archlinux,突发奇想装个SpaceVim写题 安装配置一路可以说是没有太大问题 最后在写题时出现如下问题 Error while trying to load a compilatio ...

  4. oracle数据库回滚

    线下测试数据误操作,回滚攻略--把数据捞出来,这个时间自己设置--表名一定要是:xx_tbd日期 CREATE TABLE user_tbd0718ASselect * from user as of ...

  5. PHP中比较有用的几个函数

    php_check_syntax 这个函数可以用来检查特定文件中的PHP语法是否正确. highlight_string 当你想要把PHP代码显示到页面上时,highlight_string()函数就 ...

  6. POJ 2570 Fiber Network(最短路 二进制处理)

    题目翻译 一些公司决定搭建一个更快的网络.称为"光纤网". 他们已经在全世界建立了很多网站.这 些网站的作用类似于路由器.不幸的是,这些公司在关于网站之间的接线问题上存在争论,这样 ...

  7. bzoj1012: [JSOI2008]最大数maxnumber(貌似是道线段树喔)

    1012: [JSOI2008]最大数maxnumber 题目:传送门 题解: 发现自己空了一道水题... 1~210000建线段树,其实就是一道裸题... 单点修改+区间查询...1A~ 代码: # ...

  8. 1.Windows7下安装与破解IntelliJ IDEA2017

    转自:https://www.cnblogs.com/justuntil/p/7245170.html IDEA 全称 IntelliJ IDEA,是Java语言开发的集成环境,IntelliJ在业界 ...

  9. Hadoop框架基础(二)

    ** Hadoop框架基础(二) 上一节我们讨论了如何对hadoop进行基础配置已经运行一个简单的实例,接下来我们尝试使用eclipse开发. ** maven安装 简单介绍:maven是一个项目管理 ...

  10. Oracle 建表

    -- Create table create table STUDENT ( sno ) not null, sname ) not null, ssex ) not null, sbirthday ...