CSDN hero program competition
QUESTION Report game (2)
Address http://hero.csdn.net/
Code mounting gpl
Question details
There are N people (numbers 1-N) standing in a row to play the report game. The reporting process may take many rounds, with the following rules:
(1) If there are no more than three people remaining, the game will end.
(2) report the number of people, and then leave the odd number of people to continue the game, or leave the even number of people to continue the game.
Repeat the two steps (1) (2) until the end of the game.
Q: What are the cases of the remaining three groups? (Note: it is a three-person group. For example, if there are two or one remaining persons, they are not included in the result ).
Input n, (0 Output the final result.
# Include
Int how (int x) {static int a; // number of group 3 if (x> 3) // when the number of group members is greater than 3, take the child column {if (x % 2 = 0) // when the number of people is an even number {howmany (x/2); // obtain the odd howmany (x/2 ); // obtain the even number} else // when the number of students is odd book {howmany (x/2 + 1); // obtain the odd number of howmany (x/2 ); // obtain the even number} else if (x = 3) // when the number of three persons is 3, the number of three persons increases by 1 a ++; return ;} // start prompt: the start unique identifier of the Automatic Marking. Do not delete or add it. Int main (void) {printf ("% d", howmany (7); return 0;} // end // prompt: the unique identifier of Automatic Marking, do not delete or add.