A - Large Digits Editorial by CoderAnshu
The answer is just the maximum of sum of digits of A and sum of digits of B.
Sample Code (C++)
#include<iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int A,B;
cin >> A >> B;
int sumA = 0, sumB = 0;
while(A)
{
sumA += A%10;
A /= 10;
}
while(B)
{
sumB += B%10;
B /= 10;
}
cout << max(sumA,sumB) << "\n";
return 0;
}
Sample Code (Python)
def Sum(n):
sum = 0
for digit in str(n):
sum += int(digit)
return sum
A, B = map(int,input().split())
print(max(Sum(A),Sum(B)))
posted:
last update: