| 12
 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
 
 | #include<iostream>#include<algorithm>
 #include<cmath>
 #define Max 100000
 #define R 16
 #define Q 8
 #include<string.h>
 using namespace std;
 char T[Max],G[Max];
 int main()
 {
 int n;
 cin>>n;
 while(n--)
 {
 long long m=1,temp=0;
 cin>>T;
 
 while(T[m]) { m++;}
 for(int i=0;i<m;i++)
 {
 if(T[i]>='0'&&T[i]<='9')
 {
 temp=temp+(T[i]-'0')*pow(R,m-1-i);
 }
 else
 {
 temp=temp+(T[i]-'A'+10)*pow(R,m-i-1);
 }
 }
 
 int i=0; m=1;
 while(temp)
 {
 G[i]=fmod(temp,Q)+'0';
 temp=temp/Q;
 i++;
 }
 while(G[m]) { m++;}
 int j=m-1;
 for(int i=0;i<m/2;i++)
 {
 swap(G[i],G[j]);
 j--;
 }
 cout<<G;
 }
 
 return 0;
 }
 
 |