#P8044. Collision of Integers
Collision of Integers
Collision of Integers
When two integers collide, they interact digit by digit. First, add leading zeros to the number with fewer digits until both have the same number of digits. Then, starting from the least significant digit (the rightmost digit) and moving towards the most significant digit, compare the corresponding digits of the two integers. In each comparison, remove the smaller digit from its original number. If the digits are equal, do nothing. After processing all digits, concatenate the remaining digits (in their original order) to form the new numbers. If all digits of a number are removed, output the string YODA
for that number.
For example, consider the integers \(456328\) and \(284315\). After they collide:
4 | 6 | 3 | 2 | 8 | |
8 | 3 |
The resulting numbers will be \(46328\) and \(83\).
inputFormat
The input consists of two integers n
and m
separated by space. They may have different numbers of digits.
outputFormat
Output the two new numbers after the collision. If a number has all its digits removed, output a single line with the string YODA
in its place. The two results should be output on the same line separated by a space.
sample
456328 284315
46328 83