Curtain @ 2017-01-29 17:15:36
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long long a,b,toto,c;
cin>>a>>b;
toto=a;
for(int i=1;a>0;++i)
{
a=a/b;
c=a%b;
toto+=a;
if((a+c)/b!=0)
continue;
}
cout<<toto;
return 0;
}
by owogon @ 2017-01-29 20:16:26
可不可能是因为计算Peter余下的烟头数目计算时忘了加上没有兑换烟的烟头?P党表示不太懂C的程序
by 小凯玩具kevin @ 2017-03-19 18:20:51
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,x,a,b;
cin>>x>>n;
b=x;
do
{
a=x/n;
b=a+b;
x=x+a-a*n;
}
while(x>=n);
cout<<b<<endl;
}