cigarettes
来源:互联网 发布:腾讯云如何解析端口号 编辑:程序博客网 时间:2024/04/30 05:05
题目94
cigarettes
时间限制:3000 ms | 内存限制:65535 KB
难度:2
- 描述
Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them
one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette.
Now,do you know how many cigarettes can Tom has?
- 输入
- First input is a single line,it's n and stands for there are n testdata.then there are n lines ,each line contains two integer numbers giving the values of n and k.
- 输出
- For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.
- 样例输入
34 310 3100 5
- 样例输出
514124
#include<iostream>
using namespace std;
int main(){
int test,m,n,i,k,s;
cin>>test;
while(test--){
int s;
cin>>m>>n;
s=m;
i=m;
while(i>=n){
s=s+i/n; //可换的烟
i=i/n+i%n; //现有的烟蒂
}
cout<<s<<endl;
}
return 0;
}
0 0
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- cigarettes
- NYOJ - cigarettes
- nyoj-cigarettes
- 94 cigarettes
- NYOJ-cigarettes
- 94 cigarettes
- printf&scanf的格式化代码详解
- 学习android 一个月开发的看小说app(文云阁)
- hdu 2112:HDU Today
- 用PHP校验EMAIL地址的正确方法
- 关于jquery的绑定方法
- cigarettes
- java并发编程实践学习笔记
- CF 394A:Counting Sticks
- JNDI 在 J2EE 中的角色
- java招聘技术准备
- 精 挑 细 选
- C#面向对象的卓越设计
- POJ 1789 Truck History
- CF 394B:Very Beautiful Number