Time Limit: 1000msMemory Limit: 32768KB 64-bit integer IO format: %I64d Java class name: Main
Submit Status PID: 24433
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
我感觉这题很是变态,我想了好长时间,都没想出什么意思,真的崩溃了
这里写代码片
这题我也是想了很长时间,还是做题少吧
1.
列表内容
----
#include <iostream>
using namespace std;
int main()
{
int n,k;
int sum;
while(cin>>n>>k)
{
sum=n;
while(n>=k)
{
sum+=n/k;
n=n/k+n%k;
}
cout<<sum<<endl;
}
return 0;
}