水题,直接模拟即可,复杂度 O(logn)

#include<bits/stdc++.h>
using i64 = long long;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    i64 n;
    std::cin >> n;

    i64 n_ = 0, sum = n;
    while (n) {
        n_ *= 10;
        n_ += n % 10;
        n /= 10;
    }
    std::cout << sum + n_;

    return 0;
}

https://www.nowcoder.com/discuss/727521113110073344