#148. 条件求和:位数判断
条件求和:位数判断
Conditional Sum
Background
Congcong is learning about number operations. He encountered an interesting summation problem that requires determining the final result based on the number of digits in the sum.
Problem Description
Given two non-negative integers and , return their sum, so long as the sum has the same number of digits as . If the sum has more digits than , just return without . (Note: one way to compute the number of digits of a non-negative integer is to convert it to a string with String.valueOf(n) and then check the length of the string.)
Input Format
Input is given from standard input in the following format.
Output Format
Output is printed to standard output in the following format.
[result]
Sample
2 3
5
8 3
8
8 1
9
Sample Explanation
Sample 1: . . has 1 digit, and also has 1 digit. The number of digits is the same, so return . Sample 2: . . has 1 digit, but has 2 digits. The sum has more digits than , so return . Sample 3: . . has 1 digit, and also has 1 digit. The number of digits is the same, so return .
Constraints
Time limit: 1 second, Memory limit: 1024 KiB for each test case.