自己写的。C语言。题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include<stdio.h> int main() { int n[10]; int i = 0, m, sum; for (i = 0; i < 10; i++) { scanf("%d", &n[i]); if (n[i] == 0) { i = 10; } } i = 0; while (n[i] != 0) { m = n[i]; sum = 0; while (m >= 2) { if (m == 2) { sum += 1; break; } sum += m / 3; m = m / 3 + m % 3; } printf("%d\n", sum); i++; } return 0; }