题意:比给出的数大的最小回文数。
先用前n/2长对称到后面,如果没变大,在中间加1,进位,再对称。
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
using namespace std;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF; void work(string &str)
{
int bs=;
for(int i=;i<str.size()/;++i)
{
if(str[i]>str[str.size()--i])bs=;
else if(str[i]<str[str.size()--i])bs=-;
str[str.size()--i]=str[i];
}
if(bs<=)
{
int c=;
str[(str.size()-)/]+=;
for(int i=(str.size()-)/;i>=;--i)
{
str[i]+=c;
if(str[i]>'')str[i]='',c=;
else c=;
}
if(c)
{
str=""+str;
}
for(int i=;i<str.size()/;++i)
{
str[str.size()--i]=str[i];
}
}
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","w",stdout);
lon casenum;
cin>>casenum;
for(lon time=;time<=casenum;++time)
//for(;scanf("%d",&n)!=EOF;)
{
string str;
cin>>str;
work(str);
cout<<str<<endl;
}
return ;
}