The Confused Hash
Practice
0 (0 votes)
Medium
Problem
94% Success 1291 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code
Hash happens to be a very smart dog. He recently read about fibonacci numbers. His master has given him a relation similar to fibonacci recurrence as follows,
f(n) = 5 f(n-1) + 3 f(n-2)
for n > 1 and f(0) = f(1) = 1
Rather than giving him the kth number of the sequence to compute, his master has given him N numbers whose product is k and asked him to calculate the last 3 digits of f(k)
.
Hash is very confused so he asks your help to solve it. Help Hash to get the answer.
Input Format:
The first line of the input contains a single integer denoting N. (N<= 106). The second line contains N space seperated integers (<=1018).
Output Format:
Print the last 3-digit of f(k)
.
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Medium
Points:30
Tags:
Modular exponentiationMediumMatrix ExponentiationMathematics
3.Non-Fibo
Points:30
8 votes
Tags:
MathematicsMediumOpenApprovedNumber Theory
Editorial