CF379A.New Year Candles

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.

Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle.

Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number.

程序员瓦西里热爱浪漫,因此今年他决定用蜡烛来照亮自己的房间。

瓦西里有 aa 支蜡烛。当瓦西里点燃一支新蜡烛时,它首先燃烧一小时,然后熄灭。瓦西里很聪明,他能将 bb 支已熄灭的蜡烛重新制作成一支新蜡烛。由此得到的新蜡烛可以像其他任何新蜡烛一样使用。

现在瓦西里想知道:如果他采取最优策略,这些蜡烛最多能照亮房间多少小时?请帮助他求出这个数值。

输入格式

The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000).

单行包含两个整数 aa 和 bb(1 ≤ a ≤ 10001 ≤ a ≤ 1000;2 ≤ b ≤ 10002 ≤ b ≤ 1000)。

输出格式

Print a single integer — the number of hours Vasily can light up the room for.

输出一个整数——Vasily 能够点亮房间的小时数。

输入输出样例

  • 输入#1

    4 2

    输出#1

    7
  • 输入#2

    6 3

    输出#2

    8

说明/提示

Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours.

考虑第一个样例。前四个小时,瓦西里点燃新的蜡烛;随后,他用四支燃尽的蜡烛制作出两支新蜡烛并将其点燃。当这两支蜡烛燃尽(停止燃烧)后,瓦西里又能再制作一支蜡烛。总体而言,瓦西里能让房间保持明亮共 7 小时。

输入解题思路,AI测评打分。不知道怎么写?

首页