#P1957. 口算练习题
口算练习题
Description
Teacher Wang is teaching simple arithmetic. The meticulous Teacher Wang has collected mental calculation problems that students often get wrong and wants to compile them into a practice set. Laying out these problems is tedious, so he wants to use a computer program to improve efficiency. He hopes to minimize the input workload; for example, for the expression , it is best to input only and . The output should be as detailed as possible to facilitate later typesetting; for instance, after processing the above input, output and the total length of this expression, . Teacher Wang assigns you this task. Please write a program to implement the above functionality.
Input Format
The first line contains an integer .
The next lines each describe an expression. Each line may contain either three data items or two data items.
- If a line has three data items, then the first item is the operation type: means addition, means subtraction, and means multiplication. The next two items are the operands.
- If a line has two data items, then the operation type is the same as in the previous problem, and these two items are the operands.
Output Format
Output lines. For each input expression, output the complete expression with its result on the first line. On the second line, output the total length of that expression.
4
a 64 46
275 125
c 11 99
b 46 64
64+46=110
9
275+125=400
11
11*99=1089
10
46-64=-18
9
Hint
Constraints and Notes:
- For of the testdata, each input expression has three data items.
- For all testdata, . The first expression always has three data items. Operands are non-negative integers less than .
Translated by ChatGPT 5
京公网安备 11011102002149号