Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Moving Sticks
Description 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:- Each puzzle is made of a left operand, an operator, a right operand, an equal sign, and a result. The two operands and the result are numbers, made of one or more digits, and is less than 2
^{31}. - The operator and the equal sign cannot be changed. You’re only allowed to move sticks making up the digits.
- You can neither remove digits completely nor introduce new ones. (i.e. You can only
*alter the digits*.) - Leading zeros are allowed in both the input and output. Leading zeros in the output must be printed.
- Each puzzle specifies the number of required moves. Your solution must move as many sticks as specified. A stick is moved at most once; It cannot be moved again. If a stick is moved, its original place must remain vacant. (i.e. you cannot move another stick to that place.)
- When solving a puzzle involving division, the division must be an
*exact integer division*, i.e. no remainder. - Digits are “written” as follows:
Input Your program will be tested on one or more test cases. Each test case is specified on a single line using the following format:
where The end of the test cases is indicated by a separate line having the word Output For each puzzle, your program must print one line of the form:
Where In the case of multiple solutions, print just one. If the puzzle can’t be solved, print Sample Input 6 + 1 = 12 (1) 81 * 8 = 1 (3) 5 - 1 = 4 (1) EOF Sample Output 1. 5+7=12 2. 01*3=3 3. UNSOLVABLE Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator