#include<iostream>
using namespace std;
int main(){
    int n, k;
    while(cin >> n >> k){
        int t = n;
        int coupon = n;
        while(coupon >= k){
            int newchicken = coupon / k;
            t += newchicken;
            coupon = coupon % k + newchicken;
        }
        cout << t << "\n";
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: