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

建议使用的浏览器:

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

3516:Johnny Hates Math

Special Judge 特殊评判
题目描述

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.

输出解释

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), 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.

输入样例
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
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 12000MS

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

源链接: POJ-3516

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

共提交 0

通过率 --%
时间上限 内存上限
20000 393216