内部比赛 G A Game with Marbles
2013-09-11 14:07
766 查看
A Game with Marbles
Time Limit: 1000MS Memory limit:
65536K
题目描述
Thereare n bowls, numbered from 1 to n. Initially,
bowl i contains mi marbles. One game step
consists of removing one marble from a bowl. When removing a marble
from bowl i (i > 1), one marble is
added to each of the first i-1 bowls; if a marble is removed
from bowl 1, no new marble is added. The game is finished
after each bowl is empty.Your job is to determine how many game
steps are needed to finish the game. You may assume that the supply
of marbles is sufficient, and each bowl is large enough, so that
each possible game step can be executed.
Input Specification
The input contains several test cases.Each test case consists of one line containing one integer n
(1 ≤ n ≤ 50), the number of bowls in the game. The following
line contains nintegers mi (1 ≤ i ≤ n,
0 ≤ mi ≤ 1000), where mi gives the
number of marbles in bowl i at the beginning of the
game.The last test case is followed by a line
containing 0.
输入
Theinput contains several test cases. Each test case consists of one
line containing one integer n (1 ≤ n ≤ 50), the
number of bowls in the game. The following line contains
nintegers mi (1 ≤ i ≤ n, 0 ≤
mi ≤ 1000), where mi gives the
number of marbles in bowl i at the beginning of the
game.The last test case is followed by a line
containing 0.
输出
Foreach test case, print one line with the number of game steps needed
to finish the game. You may assume that this number fits into a
signed 64-bit integer (in C/C++ you can use the data type "long
long", in JAVA the data type "long").
示例输入
示例输出
相关文章推荐
- 内部比赛 A Alfredo\'s Pizza Res…
- 内部比赛C Convert Kilometers to …
- 内部比赛 E El Dorado
- poj 2996 Help Me with the Game
- Windows Game Note2
- Program exited with code  ****
- MSSQL2008:解密with encryption加…
- Cool Tips and Tricks with ASP.NET 2.0 posted by Scott
- with check option的学习
- poj 3225 Help with Intervals
- HDOJ  1846   Brave Game
- poj 3468 A Simple Problem with I…
- Integration with ZF2
- Tip/Trick: Implement Copy Function with FormView and SqlDatasource
- FAT32 doesn't support files with…
- 内部赛3 B Black and white painti…
- 通过 Frame来实现页面内部导航
- POJ 1753 Flip Game
- HDU 1285 确定比赛名次(拓扑排…
- 安卓自定义标题时候you cannot combine custom titles with other