题解 | #汽水瓶#
汽水瓶
http://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include <stdio.h>
//f1 = 0
//f2 = 1;
//f3 = 1+f1;
//f4 = 1+f2;
int main()
{
unsigned int N = 0;
unsigned int a = 0;
unsigned int b = 0;
unsigned int c = 0;
while (scanf("%d", &N)) {
//printf("^^^^%d", N);
if (N == 0) {
break;
}
while (N > 1) {
a = N / 3; //已经喝的;
b = N % 3; //剩余的;
N = a+b;
c += a;
if (N == 2) {
c++;
break;
}
}
printf("%d\n", c);
c = 0;
}
return 0;
}