CF - 379A. New Year Candles - 模拟
1.题目描述:
1 second
256 megabytes
standard input
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.
The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000).
Print a single integer — the number of hours Vasily can light up the room for.
4 2
7
6 3
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
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 - 模拟相关推荐
- 【CF#148B】Escape(模拟)
题干: The princess is going to escape the dragon's cave, and she needs to plan it carefully. The princ ...
- CF #366(div.2) C 模拟,思维
CF #366(div.2) C. Thor 题意:一个手机n个联系人,有q个操作.每次给出ty和ai,如ty==1,表示收到ai的一条信息:如ty==2,表示将ai发的信息都看掉:如ty==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 ...
- 【CF#2A】Winner(模拟 STL-map)☆
题干: The winner of the card game popular in Berland "Berlogging" is determined according to ...
- 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 ...
- dev treeview控件_在winform中怎样实现好看的treeview样式
aaa aaaa 来自为知笔记(Wiz) 序列化与反序列化成XML http://blog.itpub.net/12639172/viewspace-490786/ 现在XML都普遍的用到了很多地方, ...
- css3伪类和伪元素基本使用
一.介绍 css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类--:hover,:link,:active,:target,:not(),:focus. 常见伪元素--::first-let ...
- HTML:::before和::after伪元素的用法
随笔 - 366 文章 - 0 评论 - 392 ::before和::after伪元素的用法 一.介绍 css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类--:hover,:link ...
- ZooKeeper 相关概念总结
文章目录 前言 1.ZooKeeper 介绍 1.1.ZooKeeper 概览 1.2.ZooKeeper 特点 1.3.ZooKeeper 应用场景 1.3.1.分布式锁 1.3.2.命名服务 1. ...
最新文章
- 在学习Python中,这个知识我们一定要看一遍,记不住没关系单一定要知道,字符串常用函数用法
- QT的QStack类的使用
- LR通过SiteScope监控mysql
- [dp] LeetCode 62. Unique Paths
- Symbian手记【三】 —— Symbian的描述符
- python分析UFO报道数据
- JIRA重启服务器后需要重启TOMCAT的解决
- 趋势OFFICESCAN忘记卸载密码时如何卸载客户端
- linux服务器使用WonderShaper进行带宽限制
- linux dd 错,dd命令错误写入设备上没有剩余空间[关闭](dd command error writing No space left on device [closed])...
- 从盘古开天辟地说起JVM性能调优
- 清华计算机系出了哪些牛人,清华大学16位学霸PK 简历吓坏网友
- o2o现状及未来发展趋势是什么?
- Linux中编写Shell脚本
- vue实现微信扫码拨打电话
- 最高法规定网络转载涉嫌侵权需担责 10月10日起施行
- Android四大天王
- ath9k驱动内的数据发送过程
- flv视频怎么转换成mp4格式的3种方法分享
- duoyinzi_pinyin