22402_JohnnyHatesMa

2022-5-16 18:21| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506398533899-Problem List-采集的数据-后羿采集器.html

Pro.ID

22402

Title

Johnny Hates Math

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22402

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Johnny is on probation! He has failed so many math courses and the Department has forced him to register in a remedial math course. He must pass the course or he'd be expelled from the University. In an attempt to impress his professor, Johnny is typing all his assignments on the computer. The latest assignment is rather simple, Johnny was given a set of problems to solve. Each problem had a list of one or more numbers that Johnny was supposed to add. Johnny has worked all night on the assignment, neatly typing his solution to each problem using a word processor as seen here:

    4+12+3=19

    As usual, Johnny woke up late, he hardly had the time to print the assignment and rush to class. Only in the classroom did he discover that, due to a printer driver problem, non of the plus signs were printed. The above line was printed as:

    4123=19

    Write a program to figure out where the pluses are supposed to be. All what Johnny remembers is that all the numbers were positive; None of the numbers, other than possibly the sum, had more than 5 digits; And none of the numbers had a zero as the left-most digit.

    输入

    Your program will be tested on one or more expressions. Each expression is specified on a single line. No line will be longer than 256 characters. The last line, which is not part of the test cases, will be 0=0.

    输出

    Description

    Johnny is on probation! He has failed so many math courses and the Department has forced him to register in a remedial math course. He must pass the course or he'd be expelled from the University. In an attempt to impress his professor, Johnny is typing all his assignments on the computer. The latest assignment is rather simple, Johnny was given a set of problems to solve. Each problem had a list of one or more numbers that Johnny was supposed to add. Johnny has worked all night on the assignment, neatly typing his solution to each problem using a word processor as seen here:

    4+12+3=19

    As usual, Johnny woke up late, he hardly had the time to print the assignment and rush to class. Only in the classroom did he discover that, due to a printer driver problem, non of the plus signs were printed. The above line was printed as:

    4123=19

    Write a program to figure out where the pluses are supposed to be. All what Johnny remembers is that all the numbers were positive; None of the numbers, other than possibly the sum, had more than 5 digits; And none of the numbers had a zero as the left-most digit.

    Input

    Your program will be tested on one or more expressions. Each expression is specified on a single line. No line will be longer than 256 characters. The last line, which is not part of the test cases, will be 0=0.

    Output

    For each expression in the input, your program must print a line of the form:

    k. result

    Where k is the expression number (starting at 1,)  is a single space, and result is the expression with the necessary plus signs in place. There are no spaces in result. If there are more than one possible solution, print a solution that requires the least number of plus signs. Knowing how bad Johnny is in arithmetic, it is possible that there is no solution, in which case your program should print "IMPOSSIBLE" as the result.

    Sample Input

    4123=19
    15442147612367219875=472
    111=8
    0=0

    Sample Output

    1. 4+12+3=19
    2. 15+44+21+47+61+23+67+21+98+75=472
    3. IMPOSSIBLE

    Source

    样例输入

    4123=19
    15442147612367219875=472
    111=8
    0=0

    样例输出

    1. 4+12+3=19
    2. 15+44+21+47+61+23+67+21+98+75=472
    3. IMPOSSIBLE

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部