I have stored my online judge solutions of my own :)
#include<bits/stdc++.h> using namespace std; int main() { long long n , k ,total=0, rest=0; while(cin>>n>>k){ total=n; while(n>=k){ rest=n%k; total+=(n/k); n=rest+(n/k); } cout<<total<<endl; } return 0; }
No comments:
Post a Comment