Four Arithmetic Operations
Time limit1sMemory limit128 MB
Each line gives an expression a op b = c with single-digit spacing, and you print correct or wrong answer depending on whether the arithmetic matches the claimed result.
- Level
Easy2 of 10
- Topics
- Math, Implementation, String, Brute force
- Solved
- No attempts yet
Problem
The four arithmetic operations are addition, subtraction, multiplication, and division, written in a program as +, -, *, and /. For example, 3 * 2 = 6 is a correct equation.
You are given expressions together with the answer claimed for each one. A claimed answer that equals the computed result is correct and any other claimed answer is wrong, so 3 * 2 = 6 is correct and 3 * 2 = 7 is wrong. Write a program that grades every expression it reads.
Input
Input comes from standard input. The first line holds a natural number , the number of test cases. Each of the next lines holds one expression.
An expression has the form a op b = c, and the numbers and the symbols are separated by single spaces. op is one of +, -, *, /, and exactly one operator appears in an expression. A division always comes out even. Every operand, every computed result, and every claimed answer fits in a signed 64-bit integer. A computed result can be larger than a 32-bit integer holds.
Output
Write to standard output. Print one verdict per line, in input order. Print correct when the expression is right and wrong answer when it is not.