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;
bool flag = false;
while (i[x] == '9' && x >= 0)
i[x--] = '0';
if (x >= 0) {
i[x]++;
return;
}
i = '1' + i;
}
int main() {
cin >> i;
str();
for (; check(i); str()) { }
cout << i;
return 0;
}
为什么超时啊