Problem description

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.

Input

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

Output

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

Examples

Input

4 2

Output

7

Input

6 3

Output

8

Note

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.

解题思路:题目的意思就是有a根蜡烛,每烧完一根蜡烛需要一个小时,而且每烧完b(b<=a)根蜡烛就能产生一根新的蜡烛,求这些蜡烛全部烧完需要多少个小时,水过!

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;cin>>a>>b;
for(int i=;i<=a;++i)
if(i%b==)a++;
cout<<a<<endl;
return ;
}

C - New Year Candles的更多相关文章

  1. codeforces A. New Year Candles 解题报告

    题目链接:http://codeforces.com/problemset/problem/379/A 题目意思:给定a支蜡烛(每支蜡烛可以燃烧1小时),可以在燃尽的a支蜡烛中看能组成多少组b支蜡烛, ...

  2. uvalive5810 uva12368 Candles

    题意:每组数据给出n个数,每个数在1-100,问组成这些数的蜡烛的权值的最小值.权值=把选的蜡烛从大到小排列组成的数 组成方式:比如有1 3两个蜡烛 可以组成13(1和3)或4(1+3) 只有一个加号 ...

  3. ARC 101 C - Candles

    题面在这里! 显然直接枚举左端点(右端点)就OK啦. #include<cstdio> #include<cstdlib> #include<algorithm> ...

  4. Gym - 101635K:Blowing Candles (简单旋转卡壳,求凸包宽度)

    题意:给定N个点,用矩形将所有点覆盖,要求矩形宽度最小. 思路:裸体,旋转卡壳去rotate即可. 最远距离是点到点:宽度是点到边. #include<bits/stdc++.h> #de ...

  5. Gym101635K Blowing Candles

    题目链接:http://codeforces.com/gym/101635 题目大意: 推荐一篇文章:https://blog.csdn.net/wang_heng199/article/detail ...

  6. Solution -「ABC 219H」Candles

    \(\mathcal{Description}\)   Link.   有 \(n\) 支蜡烛,第 \(i\) 支的坐标为 \(x_i\),初始长度为 \(a_i\),每单位时间燃烧变短 \(1\) ...

  7. Inverted sentences

    And ever has it been that love knows not its own depth until the hour of separation.  除非临到了别离的时候,爱永远 ...

  8. Good Bye 2013 A

    A. New Year Candles time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. HDU 5768:Lucky7(中国剩余定理 + 容斥原理)

    http://acm.hdu.edu.cn/showproblem.php?pid=5768 Lucky7 Problem Description   When ?? was born, seven ...

随机推荐

  1. Linux下/var/log/btmp文件

    今天查看了一下服务器,发现/var/log/btmp日志文件比较大占用磁盘空间,搜索一下,此文件是记录错误登录的日志,就是说有很多人试图使用密码字典登录ssh服务,此日志需要使用lastb程序打开. ...

  2. CAD处理键盘按钮被释放(com接口VB语言)

    主要用到函数说明: MxDrawXCustomEvent::KeyUp 键盘按钮被释放,详细说明如下: 参数 说明 iVk 是按钮码,如F8,的值为#define VK_F8 0x77 返回0消息继续 ...

  3. win10安装mysql 8.0.11

    mysql安装包可到官网下载,地址:https://dev.mysql.com/downloads/mysql 1.首先解压文件包,我这解压到E:\install_work\mysql目录下: 2.发 ...

  4. IE低版本和高级浏览器对文本输入事件兼容

    1 一般 使用oninput 事件可以监控文本输入事实触发 2 兼容需要使用onpropertychange . 3 兼容写法   var evenInput=DOM元素.oninput || DOM ...

  5. 理解Mysql prepare预处理语句

    MySQL 5.1对服务器一方的预制语句提供支持.如果您使用合适的客户端编程界面,则这种支持可以发挥在MySQL 4.1中实施的高效客户端/服务器二进制协议的优势.候选界面包括MySQL C API客 ...

  6. linu学习第一天:基础知识

    1 bc 计算器 2 ibase=2 以二进制输入,输出10进制 3 obase=2 输出二进制 4 enable --查看内部命令 5 #第一天的命令 6 enable --查看内部命令 7 ena ...

  7. PAT 1100. Mars Numbers

    People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...

  8. nyoj_18_The Triangle_201312071533

    The Triangle 时间限制:1000 ms  |           内存限制:65535 KB 难度:4   描述 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure ...

  9. MySQL Master High Available 理论篇(二)

  10. 小胖说事14--------IOS字体大小,字号的问题 PX转化为UIFont

    PX和Font之间相互转换公示表: 计算公式为:font=(像素PX)/(96/72).