Good Bye 2013 A
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 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.
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 Good Bye 2013很经典的面试试题。
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
using namespace std;
typedef long long LL ;
int b ; int dfs(int well ,int burn){
if(well == && burn < b)
return ;
int sum = well ;
int next_well = burn/b ;
burn %= b ;
return sum + dfs(next_well,well+burn) ;
} int main(){
int a ;
cin>>a>>b ;
cout<<dfs(a,)<<endl ;
return ;
}
Good Bye 2013 A的更多相关文章
- Hello world,Hello 2014,Bye 2013
序 想要写点什么的时候发现不知道写什么了,用一句话来总结2013的话,就是2013是既熟悉又陌生的一年,熟悉是同样的开发工作,陌生是从河南到北京的环境改变,当时大学的卧谈会,谈论毕业了要做什么,想要在 ...
- bye 2013 hello 2014
最近两个月除了必要的工作外,其余时间都在干一些我其实平时很少干的事, 喝酒.唱歌.打麻将.玩牌.以及到处跑找朋友玩,也许是过年的原因我放纵了自己,也许是自己心中的烦恼.我的博客记录着我每次看书学习的笔 ...
- Good Bye 2013 C
C. New Year Ratings Change time limit per test 1 second memory limit per test 256 megabytes input st ...
- Good Bye 2013
C:有点这种题的经验,先存起来相等的 D:赛后还搓了好久的代码,其实长度就100,枚举两边情况,其实A和C就涵盖了所有情况!所以到2就可以了,而且我弄出了有多少个后,和两边情况,也不知道能否或怎么凑成 ...
- codeforces Good Bye 2013 379D New Year Letter
题目链接:http://codeforces.com/problemset/problem/379/D [题目大意] 告诉你初始字符串S1.S2的长度和递推次数k, 使用类似斐波纳契数列的字符串合并的 ...
- CodeForces比赛总结表
Codeforces A B C D ...
- sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法
sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法 1.报错误号码2013,可能是端口号不是默认的3306,需要改成对应的,检查命令是: [root@host et ...
- 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...
- SharePoint 2013: A feature with ID has already been installed in this farm
使用Visual Studio 2013创建一个可视web 部件,当右击项目选择"部署"时报错: "Error occurred in deployment step ' ...
随机推荐
- 跑马灯标记marquee
常见属性: direction:滚动方向(left默)/right/up/down; behavior:滚动方式(scroll默)/slide/alternate来回弹动: width.height. ...
- Spring中加载多个Properties配置文件
单个配置: <bean id="propertyConfigurer" class="org.springframework.beans.factory.confi ...
- 自己常用的8个Web在线工具
为什么要用 Web 在线工具呢?有两个原因,第一,它不受限于物理平台,我既可以在自己的电脑上使用,也可以在公司或亲戚朋友的电脑上使用(不管对方的操作系统是什么,只要能上网):第二,可以解放硬盘,减少 ...
- Android之View和SurfaceView
Android之View和SurfaceView Android游戏当中主要的除了控制类外就是显示类View.SurfaceView是从View基类中派生出来的显示类.android游戏开发中常用的三 ...
- HDFS中Java的API使用测试
import java.io.IOException; import java.util.Arrays; import java.util.Date; import java.util.Scanner ...
- 简单poi读取excel
1.添加依赖jar包 maven配置: <!-- poi being --> <dependency> <groupId>org.apache.poi</gr ...
- 图片过大导致OOM
原文:http://www.codeceo.com/article/android-load-image-oom.html 一.分析 在加载图片过程中出现的OOM的几种情况: 1. 加载的图片过大 2 ...
- 第三个Sprint冲刺第五天
讨论地点:宿舍 讨论成员:邵家文.李新.朱浩龙.陈俊金 讨论问题:继续昨天的工作
- 常用加实用的Linux命令
命令是计算机执行任务的指令.可以使用命令去关闭计算机,或者列出当前目录的文件列表,或当前文本的内容,或者屏幕显示一条消息等. 下面是各种基本的命令可供参考. 1.Ls - List ls会列举出当前工 ...
- gradle 本地 配置
distributionUrl=file:///D:/react/gradle-2.4-all.zip 记住差一点都会报错 编译运行Android 我们进入AwesomeProject目录, $ cd ...