Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Basic Calculation

By KIRIN29 · Limits 1s, 512 MB

Little Klee had just learned how to do arithmetic operations. She just does operations without following any rules of mathematical expressions. She wants you to calculate the same way.

Input

The first line of input will contain T(≤100) the number of test cases. Then following each line will contain a string containing digits & operators ( +, -, * ) which stands for addition, subtraction & multiplication.

Note:

  • String will contain at most 1000 characters
  • No two operators will be together in the string

Output

Output of each test case will follow the following format:
case #x: y, where x stands for number of test case and y is the answer after the calculation.

Note:

  • As the answer could be very big, you are asked to print it modulo 109+7(1000000007)10^{9} + 7 (1000000007)
  • The final answer will always be positive

See the sample for better understanding.

Sample

InputOutput
4
1+2*3
1-10
2*2+3*4
123123123123+123123123123123123123
case #1: 9
case #2: 999999998
case #3: 28
case #4: 384389558

For case 1:

  • 1 + 2 = 3
  • 3 * 3 = 9
  • 9 modulo 10910^{9} + 7 = 9

So the final answer is 9 (as Klee doesn't want you to follow arithmetic operation rules, you just have to calculate as the digits and operators appear)

For case 2:

  • 1 - 10 = -9
  • -9 modulo 10910^{9} + 7 = 999999998

Discussion

Statistics


86% Solution Ratio

mukim_Earliest, 6M ago

rahat_chyFastest, 0.0s

gourabbLightest, 0 B

steinumShortest, 610B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.