Rejudge Progress:
1028: 糖果游戏
Time Limit: 2000 MS Memory Limit: 65536 KBTotal Submit: 341 Accepted: 166 Page View: 1438
Submit Status Discuss
Description
糖果游戏,有N(n<1000)个学生坐成一圈,每个学生最初都有偶数个糖果,当老师下口令的时候,每个学生同时都把手中糖果的一半分给右边的学生,如果某个学生手中的糖果数是奇数,那么老师就再给他一块糖果,继续进行游戏。当每个学生手中的糖果数相同的时候,游戏结束。
Input
每组testcase输入一个N表示学生数,然后N行代表每个学生最初手中的糖果数。当N为0时,输入结束。
Output
对于每组testcase输出一行,每行输出两个数,以空格隔开,分别代表游戏进行的次数和最终学生手中的糖果数。
Notes:
The game ends in a finite number of steps because:
1. The maximum candy count can never increase.
2. The minimum candy count can never decrease.
3. No one with more than the minimum amount will ever decrease to the minimum.
4. If the maximum and minimum candy count are not the same, at least one student with the minimum amount must have their count increase
6
36
2
2
2
2
2
11
22
20
18
16
14
12
10
8
6
4
2
4
2
4
6
8
0
15 14
17 22
4 8