|Online Judge||Problem Set||Authors||Online Contests||User|
Here’s a simple puzzle: Move one stick in the figure below to make the equation correct.
Easy, right? Here’s the solution:
Write a program to solve similar puzzles knowing that:
Your program will be tested on one or more test cases. Each test case is specified on a single line using the following format:
A ⊙ B = R (n)
where A, B, and R are sequences of one or more digits, but no more than nine digits. ⊙ is one of the four operators: + - * /. n is a natural number representing the number of sticks to move. One or more spaces separate A, ⊙, B, =, R, and (n).
The end of the test cases is indicated by a separate line having the word "EOF" (without the quotes).
For each puzzle, your program must print one line of the form:
Where k is the puzzle number (starting at 1), and result is the equation after solving the puzzle. result includes no spaces.
In the case of multiple solutions, print just one. If the puzzle can’t be solved, print "UNSOLVABLE" (without the quotes) as the result.
6 + 1 = 12 (1) 81 * 8 = 1 (3) 5 - 1 = 4 (1) EOF
1. 5+7=12 2. 01*3=3 3. UNSOLVABLE
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator