题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include <stdio.h> #include <string.h> #define MAX 1000 int main (){ int num[MAX] = {0}; int p, n = 0; while(scanf("%d", &num[n++]) != -1){ if(num[n - 1] == 0) break; } for(int i = 0; i < n - 1; i++){ p = 0; while(num[i] != 2){ if(num[i] == 1) break; else if(num[i] ==0) return 0; p += num[i] / 3; num[i] = num[i] / 3 + num[i] % 3; } if(num[i] == 2) p++; printf("%d\n", p); } return 0; }