Sunday, June 29, 2014

Codeforces Good Bye 2013, problem: (A) New Year Candles solution

Codeforces Good Bye 2013, problem: (A) New Year Candles: http://codeforces.com/problemset/problem/379/A

Codeforces Good Bye 2013, problem: (A) New Year Candles editorial: http://codeforces.com/blog/entry/10171

Codeforces Good Bye 2013, problem: (A) New Year Candles solution: http://ideone.com/P4aKT2

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a, b, cnt=0;
    scanf("%d%d", &a, &b);
    cnt+=a;
    while(a>=b) {
        cnt+=a/b;
        a=a/b+a%b;
    }
    printf("%d", cnt);
    return 0;
}

No comments:

Post a Comment