-
Notifications
You must be signed in to change notification settings - Fork 0
/
PALIN.cpp
56 lines (55 loc) · 1.05 KB
/
PALIN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>=b;--i)
#define ln "\n"
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define sz(a) ll(a.size())
typedef long long ll;
typedef long double ld;
map<ll,ll> counter;
std::vector<bool> visit(100002);
ll fastexpo(ll x,ll y,ll m){ll temp=1;while(y>0){if(y&1)temp = ((temp%m)*(x%m))%m;x = ((x%m)*(x%m))%m;y>>=1;}return temp;}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
int t;
cin>>t;
while(t--)
{
cin>>s;
int len=s.length();
int aux=(len)/2,f=0,no=0;
FOR(i,0,len)if(s[i]!='9')no=1;
if(!no)
{
cout<<"1";
FOR(i,0,len-1)cout<<"0";
cout<<"1"<<ln;
continue;
}
if(len%2==0)aux--;
RFOR(i,aux,0)
{
if(s[i]!='9')
{
s[i]+=1;
if(len-i-1!=i)
s[len-i-1]+=1;
break;
}
else
{
s[i]='0';
s[len-i-1]='0';
}
}
FOR(i,0,len)cout<<s[i];
cout<<ln;
}
return 0;
}