Sphere Online Judge

SPOJ Problem Set (classical)

5699. The last digit re-visited

Problem code: LASTDIG2

Pappu was doing the work of his math class about three days but he is tired of make operations a lot and he should deliver his task tomorrow. His math’s teacher gives two numbers a and b. The problem consist in find the last digit of the potency of base a and index b. Help Pappu with his problem. You are given two integer numbers: the base a (number of digits d, such that 1<=d<=1000) and the index b (0 <= b <= 922*10^15). You
have to find the last digit of a^b.

                                                         Input
The first line of input contains an integer t, the number of test cases (t <= 30). t test cases follow. For
each test case will appear a and b separated by space.

                                                         Output
For each test case output an integer per line representing the result.

Example
Input:
3
3 10
6 2
150 53
Output:
9
6
0


Added by:Hari
Date:2009-12-27
Time limit:1s
Source limit:700B
Languages:All except: CLOJ F# GO PERL 6 TECS
Resource:harrydcoder

hide comments
2010-06-28 19:50:29 Tornike Mandzulashvili
source limit is too low!!!!!!!!!!!
2010-06-27 11:44:09 Mohamed Maher
what is difference betn it and LASTDIG1
2010-05-28 20:58:53 Rudolf Brisuda
too, small source limit...

Last edit: 2010-06-14 17:51:25
2010-04-25 15:27:33 Tornike Mandzulashvili
please update it!

2010-04-25 15:26:48 Tornike Mandzulashvili
it has a low time limit !!!!!
2010-02-14 20:28:17 Hassan Aminfar
@Guo Xiaoxu
0 <= b <= 922*10^15
2010-02-14 15:16:15 ftiasch
it's "b (0 <= b <= 922*10^15)" or "b (0 <= b <= 9.22*10^15)"
2010-01-13 13:47:14 Zobayer
maheshwar, right... looking for LASTDIG3...
2010-01-07 12:17:52 maheshwar
it will be a good problem if 'b' also have 1000 digits...
2009-12-29 15:55:27 Hari
k..Time Limit Updated again to 1s.
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.