48 - ZOJ Monthly, November 2005 - 1005
Polygon game is a game played by one person. At the beginning, there is a polygon of n vertexes. Every vertex is assigned a integer number, and each edge is assigned a operator eithor "+" or "*". Each edge is ordered from 1 to n.
The first step of the game is to delete a edge from the polygon. The following n-1 steps is operated as followed:
The input will consist of a series of test cases. Each test case begins with a line of positive integer n, the number of edges of the polygon(3<=n<=50). And then the values of vertexes and operators of edges, in clockwise op,v,op,v,...,op[n],v[n], where op[i] represents the operator corresponding to the ith edge, and v[i] represents the value of the ith vertex. i=1,...,n. The value of each vertex is between -10 and 10. The input n = 0 denotes the end of the file.
For each case, just output one number: the largest value of the left vertex. One number per line.Sample Input:
3 + 3 + 4 * 2 4 + 2 * 4 + 6 * 8 0Sample Output:
Author: JIANG, Yongli