FZU 1150 Farmer Bill's Problem
2015-08-09 15:18
435 查看
Description
Peter has n cigarettes. He smokes them one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette.
How many cigarettes can Peter have?
Input
Input is a sequence of lines. Each line contains two integer numbers giving the values of n and k.
Output
For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.
Sample Input
4 3
10 3
100 5
Sample Output
5
14
124
简单数学问题
Peter has n cigarettes. He smokes them one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette.
How many cigarettes can Peter have?
Input
Input is a sequence of lines. Each line contains two integer numbers giving the values of n and k.
Output
For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.
Sample Input
4 3
10 3
100 5
Sample Output
5
14
124
简单数学问题
#include<stack> #include<queue> #include<cmath> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; const int maxn=1000005; LL T,n,m; int main() { while (~scanf("%lld%lld",&n,&m)) { T=n; while (n>=m) { T+=n/m; n=n/m+n%m; } printf("%lld\n",T); } return 0; }
相关文章推荐
- linux系统下快速切换到oracle目录下
- 第19章 网络通信----TCP程序设计基础
- Android 4.0源码下载以及编译
- 使用构造方法产生对象的原理
- 最小生成树——并查集+Kruskal(NYOJ 38 布线问题)
- FZU 1003 Counterfeit Dollar
- Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- XAMPP启动Apache:Port 443 in use by VMware-hosted.exe
- 表格
- Linq To sql入门练习 Lambda表达式基础
- MongoDB基本文件操作
- HDU4786 Fibonacci Tree(Kruskal)
- FZU 1002 HangOver
- ubuntu下lsof工具使用手册--一切皆文件
- C++类成员布局
- 优化listview列表速度
- 2015 Multi-University Training Contest 3 hdu 5318 The Goddess Of The Moon
- Triangle
- 编程中注意事项
- 懒加载中 把JSON文件转模型,复制给控制器的模型属性