#include int set_pocket(int *pocket, int n); int get_pocket(int *pocket, int n); int strike_pocket(int *pocket); int count = 0; int main(int argc, char *argv[]) { int N; // N int pocket = 0; // num of bistcuit in pocket int hand = 0; // num of bistcuit in hand int gap; // residual quantity(N - pocket) scanf("%d", &N); set_pocket(&pocket, 1); while(1) { strike_pocket(&pocket); if (pocket == N) { break; } else if (pocket*2 > N) { gap = N - pocket; hand = get_pocket(&pocket, pocket - gap); strike_pocket(&pocket); break; } } printf("%d", count); return 0; } int set_pocket(int *pocket, int n) { return (*pocket) = n; } int get_pocket(int *pocket, int n) { int ret = (*pocket); (*pocket) -= n; return n; } int strike_pocket(int *pocket) { count++; return (*pocket) *= 2; }