Friday, April 24, 2015

UVa - 10346 - Peter's Smokes

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    long long x, y, ans;
    while(cin >> x >> y){
        ans = x;
        while(x >= y){
            ans = ans + x / y;
            x = x % y + x / y;
        }
        cout << ans << endl;
    }
    return 0;
}

No comments:

Post a Comment