当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3515:Moving Sticks

Special Judge 特殊评判
题目描述

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:

  1. 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 231.
  2. The operator and the equal sign cannot be changed. You’re only allowed to move sticks making up the digits.
  3. You can neither remove digits completely nor introduce new ones. (i.e. You can only alter the digits.)
  4. Leading zeros are allowed in both the input and output. Leading zeros in the output must be printed.
  5. 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.)
  6. When solving a puzzle involving division, the division must be an exact integer division, i.e. no remainder.
  7. Digits are “written” as follows:
输入解释

Your program will be tested on one or more test cases. Each test case is specified on a single line using the following format:

AB = 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:

k. result

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

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3515

最后修改于 2020-10-29T07:03:24+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536