Pro.ID21916 TitleLazy Math Instructor Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21916 AC0 Submit0 Ratio- 时间&空间限制描述A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students may write correct answers in different forms which makes grading very hard. So, the instructor needs help from computer programmers and you can help. You are to write a program to read different formulas and determine whether or not they are arithmetically equivalent. 输入The first line of the input contains an integer N ( 1 ≤ N ≤ 20 ) that is the number of test cases. Following the first line, there are two lines for each test case. A test case consists of two arithmetic expressions, each on a separate line with at most 80 characters. There is no blank line in the input. An expression contains one or more of the following:
Note: Expressions are syntactically correct and evaluated from left to right with equal precedence (priority) for all operators. The coefficients and exponents of the variables are guaranteed to fit in 16-bit integers. 输出Description A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students may write correct answers in different forms which makes grading very hard. So, the instructor needs help from computer programmers and you can help. You are to write a program to read different formulas and determine whether or not they are arithmetically equivalent. Input The first line of the input contains an integer N ( 1 ≤ N ≤ 20 ) that is the number of test cases. Following the first line, there are two lines for each test case. A test case consists of two arithmetic expressions, each on a separate line with at most 80 characters. There is no blank line in the input. An expression contains one or more of the following:
Note: Expressions are syntactically correct and evaluated from left to right with equal precedence (priority) for all operators. The coefficients and exponents of the variables are guaranteed to fit in 16-bit integers. Output Your program must produce one line for each test case. If input expressions for each test data are arithmetically equivalent, "YES", otherwise "NO" must be printed as the output of the program. Output should be all in upper-case characters. Sample Input 3 Sample Output YES Source 样例输入3 样例输出YES 作者 |