Incorrect Addition
Time limit2sMemory limit512 MB
Simulate digit-by-digit addition without carrying for three numbers under all orderings, then report whether the resulting sums differ and list each distinct sum.
- Level
Medium4 of 10
- Topics
- Simulation, Implementation, Math, Brute force
- Solved
- No attempts yet
Problem
Volodya wrote a program that adds two numbers in column form. Unfortunately, he did not figure out how to correctly carry a digit from one place to the next. So the program works as follows. First it adds the last digits of both numbers and writes down the result, whether it is one digit or two. Then the program adds the second-to-last digits of both numbers and appends the result to the left of the previous result. The process then repeats for all remaining places.
If one number has fewer digits than the other, the program assumes that the corresponding places of the shorter number contain zeros.
Fedya wants to prove to Volodya that his addition method is not associative. In particular, Fedya claims that there exist three numbers for which the order in which they are added matters.
Fedya even gave an example of three such numbers. Help Fedya and Volodya determine whether adding these numbers in different orders can produce different sums.
Input
The input file contains three integers a, b and c (1 ≤ a, b, c ≤ 1 000 000).
Output
In the first line of the output file, print YES if the given three numbers can be added in different orders to obtain different sums. Otherwise print NO.
In the following lines, print all possible sums that can be obtained by adding a, b and c. Print the numbers one per line in increasing order.