Submit | All submissions | Best solutions | Back to list |
LASTDIG - The last digit |
Nestor 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 him two numbers a and b. The problem consist of finding the last digit of the potency of base a and index b. Help Nestor with his problem. You are given two integer numbers: the base a (0 <= a <= 20) and the index b (0 <= b <= 2,147,483,000), a and b both are not 0. You have to find the last digit of ab.
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: 2 3 10 6 2
Output: 9 6
Added by: | Jose Daniel Rodriguez Morales |
Date: | 2008-12-01 |
Time limit: | 1s |
Source limit: | 700B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: GOSU |
Resource: | Own |
hide comments
|
||||||||||||||
2014-06-29 21:48:02 excursionist
AC in Both c And Python easy one |
||||||||||||||
2014-06-28 08:51:03 Shivam Bhardwaj
W.A. :| .... And its correct in my compilier -_- |
||||||||||||||
2014-06-25 11:46:01 HUNG-SI-QUAN
can anyone check my code <snip> Last edit: 2023-06-12 22:46:59 |
||||||||||||||
2014-05-29 21:37:52 Akash Srivastava
Your solution is too long for this problem, the limit is 700 bytes! ?? Please help me out with this msg!!! |
||||||||||||||
2014-05-07 20:35:43 Rishab Banerjee
700 Bytes LOL... never seen such a problem before eliminate the spaces and indentations |
||||||||||||||
2014-04-14 14:30:48 मोहन
AC |
||||||||||||||
2014-04-08 17:01:02 [Lakshman]
@anonymous built in function is not efficient for large values, max values you can compute with pow is pow(2,63).You can solve this problem using modular exponentiation http://en.wikipedia.org/wiki/Modular_exponentiation Last edit: 2014-04-08 17:02:15 |
||||||||||||||
2014-04-08 16:10:00 anonymous
Dont know why it is giving wrong answer. :\ <snip> Last edit: 2023-06-12 22:47:03 |
||||||||||||||
2014-03-21 13:31:24 Gaurav Agrawal
can some 1 check my code ? <snip> Last edit: 2023-06-12 22:47:08 |
||||||||||||||
2014-03-21 13:21:36 Gaurav Agrawal
sry for posting code ..i'll not do it again... |