#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { if(n == 0) return 0; int numofsoda = 0; while (n >= 3) { numofsoda += n/3; n = n/3 + n%3; } if(n == 2) { numofsoda++; } printf("%d\n", numofsoda); } return 0; }
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { if(n == 0) return 0; int numofsoda = 0; while (n >= 3) { numofsoda += n/3; n = n/3 + n%3; } if(n == 2) { numofsoda++; } printf("%d\n", numofsoda); } return 0; }