AC不了...... (60%)
請求大神告訴我拿裡錯了,謝謝
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
long long n, k = 0;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if ((s[i] - '0') % 2 != 0) {
k = pow(10, s.size() - i - 1);
break;
}
}
if (k) {
cout << min(abs((stol(s) + k) / k * k - stol(s)), abs((stol(s) - k) / k * k - stol(s)));
} else {
cout << 0;
}
}