TLE:#1,#9,#10
第一次写高精(连A+B Problem都没写过,没学过高精,完全按照自己的想法写,大佬勿喷)
#include <bits/stdc++.h>
using namespace std;
bool check(string x) {
for (int k = 0, j = x.size() - 1; j >= 0 && k < x.size(); k++, j--)
if (x[k] != x[j])
return true;
return false;
}
string i;
void str() {
int x = i.size() - 1;
while (i[x] == '9' && x >= 0)
i[x--] = '0';
if (x >= 0) {
i[x]++;
return;
}
i = '1' + i;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
cin >> i;
str();
for (; check(i); str()) { }
cout << i;
return 0;
}
超时了aaa,求调