A hard puzzle
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 13437 accepted submission (s): 4677
Problem descriptionlcy gives a hard puzzle to feng5166, LWG, jgshining And Ignatius: gave a and B, how to know the ^ B. everybody 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 ^ B's the last digit number. but everybody is too lazy to slove this problem, so they remit to you who is wise.
Inputthere are mutiple test cases. Each test cases consists of two numbers a and B (0 <a, B <= 2 ^ 30)
Outputfor each test case, you should output the ^ B's last digit number.
Sample input7 66
8 800
Sample output9
6
Authoreddy
Recommendjgshining
# Include < Stdio. h >
Int Main ()
{
Int A, B;
Int T;
Int Res;
While (Scanf ( " % D " , & A, & B) ! = EOF)
{
T = A % 10 ;
Res = 1 ;
While (B)
{
If (B % 2 ! = 0 )
{
Res * = T;
Res % = 10 ;
}
T = T * T;
T % = 10 ;
B /= 2 ;
}
Printf ( " % D \ n " , Res);
}< BR >}