Code-forces 491-A 水题

题面

Hiking club “Up the hill” just returned from a walk. Now they are trying to remember which hills they’ve just walked through.

It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they’ve traveled from the first stop to the second stop, on the second day they’ve traveled from the second to the third and so on, and on the last day they’ve traveled from the stop N - 1 to the stop N and successfully finished their expedition.

They are trying to find out which heights were their stops located at. They have an entry in a travel journal specifying how many days did they travel up the hill, and how many days did they walk down the hill.

Help them by suggesting some possible stop heights satisfying numbers from the travel journal.

Input
In the first line there is an integer non-negative number A denoting the number of days of climbing up the hill. Second line contains an integer non-negative number B — the number of days of walking down the hill (A + B + 1 = N, 1 ≤ N ≤ 100 000).

Output
Output N space-separated distinct integers from 1 to N inclusive, denoting possible heights of the stops in order of visiting.
Examples

样例

intput output
0
1
2 1
2
1
1 3 4 2

题意分析

大意就是有一个人爬山,给了你上山的天数和下山的天数,然后让你用
(1~N) 数列模拟每一天的高度。
(N=上山天数+下山天数+1)

那么我们就可以分成两种情况:

  1. 上山天数为0,此时每天都下山,只需要从n自减到1即可
  2. 上山天数不为0,那就是上山与下山两段,解法不唯一,这里说下我的思路,预留下山的的高度H=下山天数,然后从H+1的高度上山然后自增至上山天数后从H高度自减即可。

代码

#
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值