#include<bits/stdc++.h>
using namespace std;
int main()
{
long int n, k, c, d;
while(cin >> n >> k)
{
c = n;
d = 0;
while(n >= k)
{
d = n/k;
c = c + d;
n = d + (n%k);
}
cout << c << endl;
}
return 0;
}
using namespace std;
int main()
{
long int n, k, c, d;
while(cin >> n >> k)
{
c = n;
d = 0;
while(n >= k)
{
d = n/k;
c = c + d;
n = d + (n%k);
}
cout << c << endl;
}
return 0;
}
Comments
Post a Comment