Start: Jun, 27, 2019 08:30:00
2019年度暑期短学期第二天
End: Jun, 27, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: I
Result: Accepted
Time: 5ms
Memory: 1092kB
Author: 2018212212198
In contest: 1275

#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;
}