编程介的小学生 2019-08-19 22:45 采纳率: 20.5%
浏览 110

C语言,Digit Puzzle猜谜问题

Problem Description
If you hide some digits in an integer equation, you create a digit puzzle. The figure below shows two valid digit puzzles.Hidden digits are represented by squares, and other digits are shown. The numbers involved in this problem are all positive integers, written in decimal forms without leading zeros.

If a digit puzzle has a unique solution, we call it a good puzzle. Both puzzles shown above are good puzzles. The solution to the first puzzle is 7*12=84, while the solution to the second one is 11*11=121. You are already given some digit puzzles, but some of them are not good. Your task is to convert these puzzles into good ones. You can change any wildcard character (i.e. hidden digits) into a real digit, any real digit to a wildcard character, or
a real digit to another real digit, but you cannot insert or remove any character at any place. The number of changed characters should be minimized. In this problem, the puzzle is always in the form "a x b = c", and "a x b" and "b x a" should be considered different if a is not equal to b. It is allowed that all digits of both a and b are shown (e.g 12 x 34 = ****), though that puzzle is actually a simple multiplication problem. Write a program to make good puzzles.

Input
The input contains several test cases. Each test case contains three non-empty strings, x, y, z, having at most 2, 2 and 4 characters respectively. Each character is a digit or a wildcard '*', x will not begin with a zero character. The last test case is followed by a single zero, which should not be processed.

Output
For each test case, print the case number and the converted puzzle. If more than one optimal solution is found, the lexicographically first one should be printed (remember that "*" is before "0"). There is always a solution.

Sample Input
7 ** 8*


0

Sample Output
Case 1: 7 ** 8*
Case 2: ** ** 1*1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题