1.题目描述:

A. New Year Candles
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 bwent 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

2.题意概述:

a只蜡烛,每只蜡烛最多可以照1小时,同时b只已经用完的空蜡烛蜡烛可以换一只蜡烛,问你最多可以点亮房间几小时?

3.解题思路:

模拟模拟再模拟,发现学长开的这场果然是手速场

4.AC代码:

#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int a, b, ans;int main()
{while (scanf("%d%d", &a, &b) != EOF){int sum = 0;ans = 0;while (a--){ans++;sum++;if (sum % b == 0){a++;sum = 0;}}printf("%d\n", ans);}return 0;
}

CF - 379A. New Year Candles - 模拟相关推荐

  1. 【CF#148B】Escape(模拟)

    题干: The princess is going to escape the dragon's cave, and she needs to plan it carefully. The princ ...

  2. CF #366(div.2) C 模拟,思维

    CF #366(div.2)  C.  Thor 题意:一个手机n个联系人,有q个操作.每次给出ty和ai,如ty==1,表示收到ai的一条信息:如ty==2,表示将ai发的信息都看掉:如ty==3, ...

  3. CF #499 div2 C. Fly(模拟)

    output standard output Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the ...

  4. 【CF#2A】Winner(模拟 STL-map)☆

    题干: The winner of the card game popular in Berland "Berlogging" is determined according to ...

  5. CF 1562 C. Rings (思维+模拟)

    链接 题意: 给出你一个01串,让你从中选取两端[l1,r1],[l2,r2][l_1,r_1],[l_2,r_2][l1​,r1​],[l2​,r2​],(l1,r1)(l_1,r_1)(l1​,r ...

  6. dev treeview控件_在winform中怎样实现好看的treeview样式

    aaa aaaa 来自为知笔记(Wiz) 序列化与反序列化成XML http://blog.itpub.net/12639172/viewspace-490786/ 现在XML都普遍的用到了很多地方, ...

  7. css3伪类和伪元素基本使用

    一.介绍 css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类--:hover,:link,:active,:target,:not(),:focus. 常见伪元素--::first-let ...

  8. HTML:::before和::after伪元素的用法

    随笔 - 366  文章 - 0  评论 - 392 ::before和::after伪元素的用法 一.介绍 css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类--:hover,:link ...

  9. ZooKeeper 相关概念总结

    文章目录 前言 1.ZooKeeper 介绍 1.1.ZooKeeper 概览 1.2.ZooKeeper 特点 1.3.ZooKeeper 应用场景 1.3.1.分布式锁 1.3.2.命名服务 1. ...

最新文章

  1. 在学习Python中,这个知识我们一定要看一遍,记不住没关系单一定要知道,字符串常用函数用法
  2. QT的QStack类的使用
  3. LR通过SiteScope监控mysql
  4. [dp] LeetCode 62. Unique Paths
  5. Symbian手记【三】 —— Symbian的描述符
  6. python分析UFO报道数据
  7. JIRA重启服务器后需要重启TOMCAT的解决
  8. 趋势OFFICESCAN忘记卸载密码时如何卸载客户端
  9. linux服务器使用WonderShaper进行带宽限制
  10. linux dd 错,dd命令错误写入设备上没有剩余空间[关闭](dd command error writing No space left on device [closed])...
  11. 从盘古开天辟地说起JVM性能调优
  12. 清华计算机系出了哪些牛人,清华大学16位学霸PK 简历吓坏网友
  13. o2o现状及未来发展趋势是什么?
  14. Linux中编写Shell脚本
  15. vue实现微信扫码拨打电话
  16. 最高法规定网络转载涉嫌侵权需担责 10月10日起施行
  17. Android四大天王
  18. ath9k驱动内的数据发送过程
  19. flv视频怎么转换成mp4格式的3种方法分享
  20. duoyinzi_pinyin

热门文章

  1. 创业初期的时候,一定要亲力亲为
  2. html tabcontrol模板,自定义TabControl 分页标题样式
  3. Praat脚本-013 | 无需标注自动切除音频首尾静音段
  4. oracle数据库学习总结
  5. 手机壳鸿蒙,手机壳后面为什么要放钱?好多人都不懂,看完我也放一张
  6. 【老师见打系列】:我只是写了一个自动回复讨论的脚本~
  7. Sublime3 设置 Fortran 代码高亮
  8. 父类引用指向子类对象的问题,即父类 对象名=new 子类
  9. odoo模块更新失败,命令行更新模块
  10. 疯狂的程序员-第三十六章