Start: Jan, 08, 2018 19:10:00
2017年秋季学期程序设计基础(C语言)期末考试
End: Jan, 08, 2018 21:40:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 5ms
Memory: 1092kB
In contest: 1139

#include<stdio.h>
int main() {
	long n,m,t,i,j,k,p;
	long f[100];
	char ch;
	scanf("%ld%c",&t,&ch);
	while (t--) {
		for (i=1;i<=8;++i) {
			scanf("%c",&ch);
			if (ch>='0'&&ch<='9') p=ch-48;
			else p=ch-87;
			for (j=i*4;j>=i*4-3;--j) {f[j]=p%2;p=p/2;}
		}
		scanf("%ld",&n);scanf("%ld%c",&m,&ch);
		for (i=n;i>=1;--i) {f[i]=m%2;m=m/2;}
		for (i=1;i<=8;++i) {
			p=f[i*4]+f[i*4-1]*2+f[i*4-2]*4+f[i*4-3]*8;
			if (p<10) printf("%ld",p);
			else printf("%c",p+87);
		}	
		printf("\n");
	}
}