abc187_a - Large Digits

Time complexity: $O(1)$

Memory complexity: $O(1)$

Click to show code.


using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int d(char c) { return c - '0'; }
int s(string x) { return d(x[0]) + d(x[1]) + d(x[2]); }
int main(void)
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    string a, b;
    cin >> a >> b;
    int sa = s(a), sb = s(b);
    cout << (sa >= sb ? sa : sb) << endl;
    return 0;
}