Submit | All submissions | Best solutions | Back to list |
Problem hidden on 2014-04-23 12:48:12 by Francky
WPC5B - Crypto |
The coordinators in galaxy H3 are keen on winning the Galactic Wars, as always. They have decided to take advice from their ancestors who have relocated to galaxy H1, through a secure computer connection. However, this would be considered a violation of the Model Code of Conduct, and hence the channel needs to be completely secure, so that the Inter-Galactic Police cannot intercept their communication
H3 citizens also know the ancient magical technique of finding the first (least-significant) digit of a^b for any integers a and b as quickly as snap. Pande and Pande have recently collaborated, for the first time ever, and produced a brilliant encryption verification algorithm using this fact. The coordinators would pick two numbers a, b and transmit it. The ancestors in H1 would calculate a^b and return it. If the correct a^b was returned, it would mean that the targetted people were sitting at the other end.
As a Martian intern at the Inter-Galactic Police, you intend to become famous by cracking this connection. Can you find the ancient technique?
Input:
First line contains a single integer T, denoting the number of Test Cases.
T lines containing space separated integers: a and b, denoting the test case you have to crack.
Warning: Fast IO may be needed in some languages.
Output:
Output T lines each containing the least significant digit of a^b, needed to break the encryption system.
Note: 0^0 = 1
Constraints:
1 <= T <= 1000000
1 <= a <= 10^18
0<= b <= 10^18
Time Limit: 1 second
Example:
Input:
1
2 3
Output:
8
Explanation: 2^3 = 8.
Added by: | triveni |
Date: | 2014-03-29 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | ACA judge IITK, WPC5 |
hide comments
|
|||||
2014-04-23 12:47:31 Francky
This problem is too near from LASTDIG, no need to make duplicates. Moved to tutorial, and hidden. There's too LASTDIG2... |
|||||
2014-04-23 09:23:07 sankar
Here is one test case 1 100000000000000876 1000000000000728 Answer is 6 |
|||||
2014-04-23 09:20:54 sankar
@Keyser Soze, We have to find the last digit of a^b |
|||||
2014-04-20 07:46:43 Hamim Raavi
my 100th classical |
|||||
2014-04-19 20:15:44 Nishanth Vijayan
what exactly are we supposed to find? a^b or lastdigit of a^b? |
|||||
2014-04-13 20:43:56 Shuvojit Saha
which algorithm i use to solve this problem |
|||||
2014-04-02 14:39:33 Atul Aditya
@triveni could u check my sol...im getting wa..even though its working for all cases submission id.. 11376641 |
|||||
2014-04-01 20:24:18 Kanish_The_Vista
Last edit: 2014-04-02 18:15:25 |
|||||
2014-04-01 18:11:18 [Lakshman]
@Triveni Mahatha can you check my last submission getting WA. |