Mehta and the Evil Strings
Practice
5 (1 votes)
Medium
Linear algebra
Matrix exponentiation
Bitmask
Algorithms
Mathematics
Open
Approved
Problem
56% Success 102 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Background:
Mehta had a horrible nightmare in which he dreamt of the Evil String. The impact of that string was so much that it forced Mehta to calculate the number of possible Evil Strings after he woke up.

Task:
Mehta is afraid to code right now. So, he mails you the required conditions to calculate the number of possible Evil Strings. Some properties of these strings include:-

They are of given specific length.
They consist of digits only between 0-9 (both inclusive).
They may have leading zeros.
They have certain Evil Product which is defined as product of digits in the string.
Their F(Evil Product) is always greater than 0.

F(P) is calculated as Bitwise XOR of all the prime factors of P.

For eg: 12 is written as 22 * 31
Therefore, F(12) = 2 xor 2 xor 3 = 3

Input:
First line of the input consists of number of testcases T
Next T lines consists of length of the Evil String N

Output:
Print the number of possible Evil Strings modulo 10^9+7 of given length N for each test case in a separate line.

Constraints:
Subtask 1:
1 <= T <= 100
1 <= N <= 105
Subtask 2:
1 <= T <= 10
1 <= N <= 1018

Note:
Leading zeros in the string also contribute to its product of digits which would be zero anyway.

Problem statement in native language : http://hck.re/Lo1koZ

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Medium
Points:30
Tags:
Medium
Points:30
27 votes
Tags:
Graph TheoryLinear AlgebraApprovedMediumAlgorithmsMathematicsOpenMatrix Exponentiation