Untitled
unknown
c_cpp
4 years ago
445 B
8
Indexable
#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;
}
Editor is loading...