
ZOJ Problem Set  2626
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 n1 steps is operated as followed: Input: 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[1],v[1],op[2],v[2],...,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. Output: 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: 20 240 Author: JIANG, Yongli Source: ZOJ Monthly, November 2005 