I have written the following code for the http://ift.tt/1yQ6C2s, which I have tested thoroughly. I have tried running it on all the corner cases and also on some very typical inputs like 0 and 1. It ran successfully each time, but I'm still getting WA. What might be the reason?
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--){
int a,end=1,i,unit[500],temp=1;
scanf("%d",&a);
long long b;
scanf("%lld",&b);
if(a==1){
printf("1\n");
continue;
}
if(b==0){
printf("1\n");
continue;
}
unit[0]=1;
bool goOn=true,marker=false;
while(goOn){
temp*=a;
for(i=0; i<end; i++){
if(unit[i]==(temp%10) && (temp%10)!=1)
marker=true;
}
if(marker)
goOn=false;
if(!marker){
unit[end]=(temp%10);
end++;
}
}
int tmp=b%(end-1);
if(tmp==0)
printf("%d\n",unit[(end-1)]);
else
printf("%d\n",unit[(tmp)]);
}
return 0;
}
Which might be the test case that I might be missing?
Aucun commentaire:
Enregistrer un commentaire