当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4434:Game

题目描述
Alice and Bob are playing game. Firstly, Alice drew a regular polygon with n vertices, then assigned each vertex a number.
Then Bob's goal is to change all the numbers to non-negative numbers. He can do following operation in each step: choose one vertex i, supposed Ai is the number on vertex i, then add Ai to it's left and right adjacent vertex, and turn Ai into -Ai.
Now you are to help Bob to find out the minimum step to reach his goal.
输入解释
Multiple test cases ended with EOF.
Each test case begins with one integer n, followed a line consist of by n integers representing the numbers on the vertices clockwise.

2<n≤105
|Ai| ≤ 105
|sum{Ai}| ≤ 10
输出解释
If Bob cannot end this game, then output 'Endless'(without quotes), otherwise output the minimum step for Bob to end this game.
输入样例
3
1 -2 3
输出样例
2
提示
In the sample, first turn -2 to 2, then the sequences became -1 2 1,
 then choose -1, the result is 1 1 0, all the numbers are non-negative, so the minimum step would be 2.
来自杭电HDUOJ的附加信息
Recommend zhoujiaqi2010

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4434

最后修改于 2020-10-25T23:13:29+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)