AcWing 3479. 数字反转
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, x, y, a, b, c;
int rev(int x) {
int ans = 0;
while (x) {
ans = ans*10 +x % 10;
x /= 10;
}
return ans;
}
void solve() {
while (cin >> a >> b) {
c = a + b;
a = rev(a);
b = rev(b);
if(a+b==rev(c)){
cout<<c;
}else{
cout<<"NO";
}
cout<<"\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}