Pro.ID22095 TitleEquation Solver Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22095 AC0 Submit1 Ratio0.00% 时间&空间限制描述Write a program that can solve linear equations with one variable. 输入The input will contain a number of equations, each one on a separate line. All equations are strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF): Equation := Expression '=' Expression
Although the grammar would allow to construct non-linear equations like "x*x=25", we guarantee that all equations occuring in the input file will be linear in x. We further guarantee that all sub-expressions of an equation will be linear in x too. That means, there won't be test cases like x*x-x*x+x=0 which is a linear equation but contains non-linear sub-expressions (x*x). Note that all numbers occuring in the input are non-negative integers, while the solution for x is a real number. 输出Description Write a program that can solve linear equations with one variable. Input The input will contain a number of equations, each one on a separate line. All equations are strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF): Equation := Expression '=' Expression
Although the grammar would allow to construct non-linear equations like "x*x=25", we guarantee that all equations occuring in the input file will be linear in x. We further guarantee that all sub-expressions of an equation will be linear in x too. That means, there won't be test cases like x*x-x*x+x=0 which is a linear equation but contains non-linear sub-expressions (x*x). Note that all numbers occuring in the input are non-negative integers, while the solution for x is a real number. Output For each test case, print a line saying "Equation #i (where i is the number of the test case) and a line with one of the following answers:
Print a blank line after each test case. Sample Input x+x+x=10 Sample Output Equation #1 Source 样例输入x+x+x=10 样例输出Equation #1 作者 |