题意简单,中文题目

方法:对于一个数 从左往右找相同的数 ,有就改变靠右的,同时把该数的右边全置0

注意!!!!n<0!!!

 /*

 */
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int inf = 0x3f3f3f3f;
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
const int maxm = ;
const int maxn = ; int num[ maxn ];
int64 n ; void Solve( int cnt ){
int temp = ;
int pos = -;
for( int i=;i<cnt;i++,temp *= ){
if( i+<cnt && num[i]== && num[i+]== ) continue;
if( num[i]==num[i+] ){
n += temp;
pos = i;
//printf("pos = %d\n",pos);
//printf("i = %d\n",i);
if( pos> ){
int tt = ;
while( ){
n /= ;
pos--;
tt *= ;
if( pos== ) break;
}
n *= tt;
} if( num[i]== ){
int64 nn = n;
int cc = ;
while( nn ){
num[ cc++ ] = nn%;
nn /= ;
}
}
}
}
//printf("pos = %d\n",pos);
} bool Judge( int n ){
int cnt = ;
int64 nn = n;
while( nn ){
num[ cnt++ ] = nn%;
nn /= ;
}
bool flag = true;
for( int i=;i<cnt;i++ ){
if( i+<cnt && num[i]== && num[i+]== ) continue;
if( num[i]!=num[i+] ) {}
else {
flag = false;
break;
}
}
if( flag==true )
return true;
Solve( cnt );
return false;
} int main(){
int T;
scanf("%d",&T);
while( T-- ){
//scanf("%d",&n);
cin>>n;
if( n< ){
cout<<""<<endl;
continue;
}
n ++;
memset( num,,sizeof( num ) );
while( ){
if( Judge(n)==true ) break;
}
//printf("%d\n",n);
cout<<n<<endl;
}
return ;
}
05-08 14:59