Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
445 B
2
Indexable
Never
#include <stdio.h>

int main() {
    // Write C code here
    int N, M, drank = 0, currempty = 0, currfull = 0, prevempty = 0;
    scanf("%d %d", &N, &M);
    currfull = N;
    while (1) {
        drank += currfull;
        currempty = currfull + prevempty;

        printf("%d\n", drank);
        if (currempty < M) {
            break;
        }
        currfull = currempty / M;
        prevempty = currempty % M;

    }
    
    return 0;
}