Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
POJ language
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 412Accepted: 83

Description

The problem wants you to understand a new programming language, POJ language, and ask you to calculate the result of a program, which is written in this language.

The language may be described as follow (the integers mentioned here are in [-231, 231)):
  1. The syntax of this language is similar with C language, but much more simple. And the different will be mentioned as below.
  2. The length of a program written in the language will not exceed 1000 letters.
  3. The variables need not declaration. If a variable is first mentioned, the value of the variable is set to be 0. And once a variable is mentioned, it will have a global scope. The length of the name of a variable will not exceed 5.
  4. A Boolean expression has the structures: "A<B", "A==B" and "A<=B", here A is a variable or an integer, and so is B.
  5. There are three kind of normal expression I, II and III.
  6. The Normal expression I has one of the follow structures: "A=B;", "A=B+C;", "A=B-C;" and "A=B*C;", here A is an variable, B is an variable or a positive integer and C is also an variable or a positive integer. It's confirmed that the new value of A is also in [-231, 231). And it's assumed that a program will execute these expressions at most 100000 times before terminated.
  7. In the language there is a new expression that is not defined in C language, and we consider this expression as normal expression II. The expression is as: "#A;", here A is a variable. This expression terminates the program and gives the result of the program, and it is the only way to terminate a program. And it's confirmed that during the processing of the program it must meet this expression.
  8. There are only two key words in the language, "if" and "while". There kinds of structures are considered as normal expression III.
    a) The "if" sentence is as: "if(a Boolean expression){some normal expressions}".
    b) The "while" sentence is as: "while(a Boolean expression){some normal expressions}".

  9. There may be white spaces, which includes " ", "\t" and "\n", at any position except in key words, Boolean expressions, normal expressions I and normal expressions II.
  10. The program consists of some normal expressions.

Input

The input contains a program written in the POJ language.

Output

The output contains an integer, which is the result of the program.

Sample Input

aaaaa=2;

bbb=5;

while ( aaaaa<=bbb ) {
	if(ccc<10){
		ccc=ccc+aaaaa;
		}
	bbb=bbb-1;

	if(100<ccc){#aaaaa; }
}
#ccc;

Sample Output

8

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator