Connection Status:
Competition Arena > ReversedSum
SRM 417 · 2008-09-10 · by Pawa · Simple Math
Class Name: ReversedSum
Return Type: int
Method Name: getReversedSum
Arg Types: (int, int)
Problem Statement

Problem Statement

For a given positive integer X we can obtain the reversed positive integer Rev(X) by reversing the order of X's digits and removing leading zeroes. For example, if X = 123 then Rev(X) = 321; and if X = 100, then Rev(X) = 1.


You will be given two positive integers x and y. Return their reversed sum, which is defined as Rev(Rev(x) + Rev(y)).

Constraints

  • x and y will each be between 1 and 1000, inclusive.
Examples
0)
123
100
Returns: 223

As mentioned in the problem statement, Rev(123) = 321 and Rev(100) = 1. So, the reversed sum is equal to Rev(322) = 223.

1)
111
111
Returns: 222
2)
5
5
Returns: 1
3)
1000
1
Returns: 2
4)
456
789
Returns: 1461

Submissions are judged against all 73 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class ReversedSum with a public method int getReversedSum(int x, int y) · 73 test cases · 2 s / 256 MB per case

Submitting as anonymous