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 ' ...
随机推荐
- mysq常见问题
1.Reading table information for completion of table and column names You can turn off this feature t ...
- Qt之WebKit学习之绘图
void Serial::on_pushButton_clicked() { //scroll(4,0); flag_btn = true; // this->update(); //绘图绘在窗 ...
- java基础介绍(转)
很全面的介绍JAVA基础的文档 Java 编程简介,第 1 部分: Java 语言基础 http://www.ibm.com/developerworks/cn/java/j-introtojava1 ...
- 2016 - 1 - 23 xml解析 -- 语法简介
一: XML的概念 1. 一种可拓展标记语言 2. 与json一样,也是一种常用的数据交互格式 3. 一般也叫XML文档---XML Document 二: XML语法 1.一个完整的XML文档一 ...
- 05——C++自己合成的函数
C++编译器自己合成的构造函数: 默认构造函数 copy构造函数 copy assigment操作符 析构函数(编译器产生的析构时non-virtual) copy assignment(当含有con ...
- 极简版 react+webpack 脚手架
目录结构 asset/ css/ img/ src/ entry.js ------------------------ 入口文件 .babelrc index.html package.json w ...
- windows调试器尝鲜
曾几何时,我也下载过看雪论坛精华看的津津有味.可惜一直没有动手去调试,学到的x86汇编指令也忘得差不多了.最近将老机器的T4200 CPU换成了更省电,温度更低的P8800,为了支援新的VT虚拟化,特 ...
- Neo4j Cypher运行示例
示例来源: Neo4j in Action. 0 准备数据 0.1 node (user1 { name: 'John Johnson', type: 'User', email: 'jsmith@e ...
- 《Android深度探索》(卷1)HAL与驱动开发读后感
第1章:安卓系统移植与驱动开发概述 这一章主要概括的介绍了安卓驱动开发和系统移植的主要内容,对安卓与Linux驱动做了一个总体的介绍.通过对第一章的学习,使我对Linux驱动开发有了一个感性的认识.在 ...
- Jqgrid 数据格式化配置
默认格式化 $jgrid = { formatter : { integer : {thousandsSeparator: " ", defaultValue: '0'}, num ...