杭电1061

/*********************************
* 日期:2011-2-16
* 作者:SJF
* 题号:杭电1061
* 题目:Rightmost Digit
* 结果:AC
**********************************/
#include<stdio.h>
int main()
{
long int n;
int numCase,r,i;
scanf("%d",&numCase);
for(i=1;i<=numCase;i++)
{
scanf("%ld",&n);
r=n%10;
switch(r)
{
case 0:
case 1:
case 5:
case 6:
case 9:
printf("%d\n",r);
break;
case 2:
if(n%4==0)
printf("6\n");
else
printf("4\n");
break;
case 3:
if(n%4==1)
printf("3\n");
else
printf("7\n");
break;
case 4:
printf("6\n");
break;
case 7:
if(n%4==1)
printf("7\n");
else
printf("3\n");
break;
case 8:
if(n%4==0)
printf("6\n");
else
printf("4\n");
}
}
return 0;
}

你可能感兴趣的:(杭电)