Alextokc @ 2017-01-17 12:01:13
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
int64 n , k , sum=0;
cin >> n >> k;
for (int64 i=0;i<k;++i){
sum = sum + n/((int)pow(k,i));
}
cout << sum << endl;
return 0;
}
by Kidd @ 2017-01-17 13:40:34
var n,m,s:longint;
begin
readln(n,m);
s:=n;
while n>=m do
begin
s:=s+n div m;
n:=n mod m+n div m;
end;
writeln(s);
end.
by xrz2895538112xrz @ 2017-08-28 21:49:25
//我的代码,仅供参考
#include<iostream>
using namespace std;
long long N,K;
long long yan,yantou,ans;
void smoke()
{
ans+=yan;
yantou+=yan;
yan=0;
}
void exchange()
{
yan=yan+yantou/K;
yantou=yantou-yantou/K*K;
}
int main()
{
cin>>N>>K;
yan=N;//"yan" 是"香烟个数"
yantou=0;//"yantou"是"烟头个数"
while(yan!=0)
{
smoke();
exchange();
}
cout<<ans;
return 0;
}