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 ' ...
随机推荐
- ASP.NET使用Razor语法无法正确识别.cshtml文件
ASP.NET使用WebPage编程的好处之一是可以使用强大的Razor语法, 但初次使用Razor语法会碰到一个比较头疼的问题就是无法直接写一个.cshtml让浏览器去识别,查资料也没有找到相关问题 ...
- jsoup 简介
Java 程序在解析 HTML 文档时,相信大家都接触过 htmlparser 这个开源项目,我曾经在 IBM DW 上发表过两篇关于 htmlparser 的文章,分别是:从HTML中攫取你所需的信 ...
- SVN - 忽略已经提交的文件
1.在本地删除要忽略的文件 2.与资源库同步,提交删除的文件 3.忽略文件
- Autofac.Configuration 3.3.0不稳定
Autofac.Configuration程序集的作用:通过配置来实现依赖注入. 示例: 1.配置内容 <configuration> <configSections> ...
- 正则表达式学习与python中的应用
目录: 一.正则表达式的特殊符号 二.几种重要的正则表达式 三.python的re模块应用 四.参考文献 一.正则表达式的特殊符号 特殊符号可以说是正则表达式的关键,掌握并且可以灵活运用重要的pyth ...
- 使用url下载网络图片以及流介绍
使用url下载网络图片的时候,首先需要建立一个URL对象,然后使用一个输入流获取该URL中的内容.之后使用读取该输入流的内容,使用一个输出流写到本地文件中.最后关闭输入和输出流.下面是一个简单的下载代 ...
- Android使用文件存储数据
Android上最基本的存储数据的方式即为使用文件存储数据,使用基本的Java的FileOutStream,BufferedWriter,FileInputStream和BufferedReader即 ...
- svn Q&A
Q1:在svn commit的时候,会出现某某文件 is missing.这是因为此次提交时:远程repository中并没有该文件,而且本地repository也没有该文件. 具体原因: 1.可能因 ...
- 对于unallocated space的翻译 我想说几句话
在sqlserver中,当我们使用sp_spaceused查看数据库空间使用情况的时候 会看到属性unallocated space.所有的中文翻译都是“未保留供数据库对象使用的数据库空间”, 作为中 ...
- iOS红马甲项目Bug总结(2)
背景:iOS调用相机和访问图库 一.调用相机或图库: -(void)imgviewClick { ALAuthorizationStatus author = [ALAssetsLibrary aut ...