Time
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 34106 Accepted Submission (s): 12255
Problem Descriptionlcy gives a hard puzzle to feng5166,lwg,jgshining and ignatius:gave A and b,how to know the A^b.everyb Ody objects to this BT problem,so LCY makes the problem easier than begin.
This puzzle describes That:gave A and b,how to know the A^b ' s, the last digit number. But everybody was too lazy to slove the problem,so they remit to you, who was wise.
Inputthere is mutiple test cases. Each test cases consists of numbers a and B (0<a,b<=2^30)
Outputfor Each test case, you should output of the a^b ' s last digit number.
Sample Input
7 668 800
Sample Output
96
#include <stdio.h>
#include <math.h>
Main ()
{
int a,b,i,j,c,x[1000],h;
while (scanf ("%d%d", &a,&b)!=eof)
{
c=a%10;
J=1;
x[1]=a%10;
for (i=2;i<=100;i++)
{
C=C*X[1];
c=c%10;
j + +;
printf ("%d\n", c);
X[j]=c;
if (X[1]==x[j])
Break
}
h=b% (j-1);
if (h==0)
H=j-1;
printf ("%d\n", X[h]);
}
return 0;
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A Hard Puzzle