#include <cstdio>
#include <cstdlib>
#include <cstring>
const int N= 2005 ;
char Str[ N+ 5 ] ;
int a[ N+ 5 ] ;
int ret[ N+ 5 ] ;
void div ( int * A) {
int tmp= 0 ,i;
for ( i= N; i>= 0 ; i-- ) {
tmp= tmp* 10 + A[ i] ;
ret[ i] = tmp/ 2 ;
tmp% = 2 ;
}
}
void dec( int * A) {
A[ 0 ] -- ;
int i= 0 ;
while ( A[ i] < 0 ) {
A[ i] + = 10 ;
A[ ++ i] -- ;
}
}
void output( int * A) {
int i;
for ( i= N; i>= 0 ; i-- )
if ( A[ i] ) break ;
printf ( "%d" ,A[ i-- ] ) ;
for ( ; i>= 0 ; i-- ) printf ( "%d" ,A[ i] ) ;
}
void gao( ) {
scanf ( "%s" ,Str) ;
memset ( a,0 ,sizeof ( a) ) ;
memset ( ret,0 ,sizeof ( ret) ) ;
int i,j;
for ( i= strlen ( Str) - 1 ,j= 0 ; i>= 0 ; i-- ,j++ ) a[ j] = Str[ i] - '0' ;
if ( a[ 0 ] % 2 == 0 ) {
div ( a) ;
memcpy ( a,ret,sizeof ( a) ) ;
if ( a[ 0 ] % 2 == 0 ) dec( a) ;
else {
dec( a) ;
dec( a) ;
}
output( a) ;
}
else {
div ( a) ;
output( ret) ;
}
}
int main( ) {
// freopen("input.txt","r",stdin);
int Tc,i;
scanf ( "%d" ,& Tc) ;
for ( i= 1 ; i<= Tc; i++ ) {
gao( ) ;
puts ( "" ) ;
if ( i! = Tc) puts ( "" ) ;
}
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RyaW5nPgpjb25zdCBpbnQgTj0yMDA1OwpjaGFyIFN0cltOKzVdOwppbnQgYVtOKzVdOwppbnQgcmV0W04rNV07Cgp2b2lkIGRpdihpbnQgKkEpewogICAgaW50IHRtcD0wLGk7CiAgICBmb3IgKGk9TjtpPj0wO2ktLSl7CiAgICAgICAgdG1wPXRtcCoxMCtBW2ldOwogICAgICAgIHJldFtpXT10bXAvMjsKICAgICAgICB0bXAlPTI7CiAgICB9Cn0KCnZvaWQgZGVjKGludCAqQSl7CiAgICBBWzBdLS07CiAgICBpbnQgaT0wOwogICAgd2hpbGUgKEFbaV08MCl7CiAgICAgICAgQVtpXSs9MTA7CiAgICAgICAgQVsrK2ldLS07CiAgICB9Cn0KCnZvaWQgb3V0cHV0KGludCAqQSl7CiAgICBpbnQgaTsKICAgIGZvciAoaT1OO2k+PTA7aS0tKQogICAgICBpZiAoQVtpXSkgYnJlYWs7CiAgICBwcmludGYoIiVkIixBW2ktLV0pOwogICAgZm9yICg7aT49MDtpLS0pIHByaW50ZigiJWQiLEFbaV0pOwp9Cgp2b2lkIGdhbygpewogICAgc2NhbmYoIiVzIixTdHIpOwogICAgbWVtc2V0KGEsMCxzaXplb2YoYSkpOwogICAgbWVtc2V0KHJldCwwLHNpemVvZihyZXQpKTsKICAgIGludCBpLGo7CiAgICBmb3IgKGk9c3RybGVuKFN0ciktMSxqPTA7aT49MDtpLS0saisrKSBhW2pdPVN0cltpXS0nMCc7CiAgICBpZiAoYVswXSUyPT0wKXsKICAgICAgICBkaXYoYSk7CiAgICAgICAgbWVtY3B5KGEscmV0LHNpemVvZihhKSk7CiAgICAgICAgaWYgKGFbMF0lMj09MCkgZGVjKGEpOwogICAgICAgIGVsc2V7CiAgICAgICAgICAgIGRlYyhhKTsKICAgICAgICAgICAgZGVjKGEpOwogICAgICAgIH0KICAgICAgICBvdXRwdXQoYSk7CiAgICB9CiAgICBlbHNlewogICAgICAgIGRpdihhKTsKICAgICAgICBvdXRwdXQocmV0KTsKICAgIH0KfQoKaW50IG1haW4oKXsKLy8gICAgZnJlb3BlbigiaW5wdXQudHh0IiwiciIsc3RkaW4pOwogICAgaW50IFRjLGk7CiAgICBzY2FuZigiJWQiLCZUYyk7CiAgICBmb3IgKGk9MTtpPD1UYztpKyspewogICAgICAgIGdhbygpOwogICAgICAgIHB1dHMoIiIpOwogICAgICAgIGlmIChpIT1UYykgcHV0cygiIik7CiAgICB9Cn0=
compilation info
prog.cpp: In function ‘void gao()’:
prog.cpp:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp: In function ‘int main()’:
prog.cpp:60: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout