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: TECS
Resource:harrydcoder

hide comments
2010-02-14 20:28:17 Hassan Aminfar
@Guo Xiaoxu
0 <= b <= 922*10^15
2010-02-14 15:16:15 Guo Xiaoxu
it's "b (0 <= b <= 922*10^15)" or "b (0 <= b <= 9.22*10^15)"
2010-01-13 13:47:14 hu la la
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.
2009-12-29 15:48:50 Himangshu Saikia
The lower time limit will also prohibit submissions in languages like ERLANG. I believe the allowed language list should be revisited or the time limit increased to atleast 1 second.
2009-12-29 15:48:50 Ajay Nair
@rizwan : although i agree it can be in tutorial , but in some of the previous easy problems offlate some one mentioned that such problems would be a real boost for ppl starting at spoj and seeing their points climb steep !! Anyhow this problem will eventually be solved by many so i guess as well let it be in classical !!
2009-12-29 15:48:50 Hari
time limit updated.
2009-12-29 15:48:50 rizwan hudda
Also does any one feel that this should be in tutorial section?
2009-12-29 15:48:50 Hari
k..I'll confirm and update it soon
SPOJ System © 2008-2010 Sphere Research Labs. All Rights Reserved.