A. New Year Candles----模拟
来源:互联网 发布:淘宝直播视频审核范本 编辑:程序博客网 时间:2024/05/22 17:06
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 hours.
题目链接:http://codeforces.com/contest/379/problem/A
题目的意思就是说有a只蜡烛,然后每用完b只可以换一只新的蜡烛,一只蜡烛照一小时,问你最多照几小时。
直接模拟就好了。
代码:
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int main(){ int a,b; scanf("%d%d",&a,&b); int ans=0; int k=0; while(a--){ ans++; k++; if(k%b==0){ k=0; a++; } } cout<<ans<<endl; return 0;}
- A. New Year Candles----模拟
- Codeforces 379A New Year Candles(模拟)
- A. New Year Candles
- 379A - New Year Candles
- codeforces -- goodbye2013 ---A. New Year Candles
- codeforces-379A. New Year Candles
- CodeForces-379A-New Year Candles
- CodeForces 379A. New Year Candles
- CF 379A New Year Candles
- [cf]New Year Candles
- D - New Year Candles
- Codeforces New Year Candles
- Problem--379A--Codeforces--A. New Year Candles
- Codeforces//Good Bye 2013//A. New Year Candles 水题
- codeforces 379A New Year Candles(水题)
- CodeForces 379 A.New Year Candles(水~)
- CodeForces 460 A. Vasya and Socks(379A.New Year Candles)
- cf - 140 A. New Year Table(模拟)
- 学习muduo(win平台的实现,未完成)
- web.xml详解(转)
- 表单校验与文件上传
- 深入理解JS闭包
- 学习笔记----COFF文件结构
- A. New Year Candles----模拟
- 针对分类问题的单隐层前馈神经网络模型
- 解决The SDK platform-tools version ((23)) is too old to check APIs compiled with API 23
- PAT-1078 Hashing (散列表 二次探测法)
- 返回键不退出应用(返回到桌面)
- POJ
- python学习(4)
- 5.Object类
- 毛玻璃效果