Thursday, January 28, 2016

UVA 10346 | | Peter's Smokes

#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