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. GET,POST请求

    get请求 post请求

  2. Centos6.6 系统优化

    1:最小化安装 2:修改网卡 vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0HWADDR=52:54:00:0e:c2:c3TYPE ...

  3. Centos7&docker-ce&compose&wordpress

    如题,最近帮人装个WordPress,想起来用docker方便,这里做个记录. 原文:https://my.oschina.net/finchxu/blog/2877580 因为docker要求lin ...

  4. python学习笔记:第八天

    文件操作: 1.文件基本操作方法: 1.打开文件2.文件操作3.文件关闭三种基本的操作模式 r(只可读) w(只可写) a(追加) 2.读文件: # f = open('静夜思','r',encodi ...

  5. 不要在.h文件中定义变量

    今天在头文件.h中初始化了一个数组和函数,在编译的时候提示这个数组和函数重新定义了,检查后发现,犯了一个致命的错误,在头文件中定义变量... 以下引用别人的一篇说明,警示自己. C语言作为一种结构化的 ...

  6. java用jxl实现导出execl表格

    //先将需要导出的数据放到list中 //然后将list中的数据放到execl表中 @RequestMapping(params="exportExecl") public Str ...

  7. IPA打包图片错误问题

    CopyPNGFile /Users/gongihou/Library/Developer/Xcode/DerivedData/KTVgo-frborfduejxrajgpkfdaipygijow/B ...

  8. iOS开发 - 二维码的生成与读取

    二维码的生成 从iOS7開始集成了二维码的生成和读取功能 此前被广泛使用的zbarsdk眼下不支持64位处理器 生成二维码的步骤: 导入CoreImage框架 通过滤镜CIFilter生成二维码 二维 ...

  9. 基于机器学习的web异常检测——基于HMM的状态序列建模,将原始数据转化为状态机表示,然后求解概率判断异常与否

    基于机器学习的web异常检测 from: https://jaq.alibaba.com/community/art/show?articleid=746 Web防火墙是信息安全的第一道防线.随着网络 ...

  10. zzulioj--1778-- 和尚特烦恼4——有多少战斗力(gcd)

    1778: 和尚特烦恼4--有多少战斗力 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 259  Solved: 123 SubmitStatusWe ...