Result: Accepted
Time: 5ms
Memory: 1092kB
#include<stdio.h>
int change(char c){
if('0'<=c&&c<='9'){
return c-'0';
} else if('a'<=c&&c<='f'){
return c-'a'+10;
}
}
int main()
{
int T,i,j;
scanf("%d",&T);
while(T--){
int l[10][5];
int a,b,n;
char c;
getchar();
for(i=0;i<8;i++){
scanf("%c",&c);
l[i][0]= change(c);
}
scanf("%d",&a);
scanf("%d",&b);
for(i=0;i<8;i++){
n=l[i][0];
for(j=4;j>0;j--){
l[i][j]=n%2;
n=(n-n%2)/2;
}
}
int q[50];
int p=1;
for(i=0;i<8;i++){
for(j=1;j<=4;j++){
q[p]=l[i][j];
p++;
}
}
for(i=a;i>0;i--){
q[i]=b%2;
b=(b-b%2)/2;
}
for(i=1;i<=32;i=i+4){
printf("%x",q[i]*8+q[i+1]*4+q[i+2]*2+q[i+3]);
}
printf("\n");
}
return 0;
}