Problem 733
Count Good Numbers
Medium · 20 pts · Math, Recursion, Fast Exponentiation
Problem
A digit string (leading zeros allowed) is good if every digit at an even index (counting from 0) is even, and every digit at an odd index is a prime digit (2, 3, 5 or 7). Count the good digit strings of length N, modulo 1000000007. There are 5 choices for each of the ceil(N / 2) even positions and 4 for each of the floor(N / 2) odd positions, so the answer is 5^ceil(N/2) × 4^floor(N/2), computed with fast (recursive) exponentiation because N can be huge. The numbers in this problem can be larger than a 32-bit int can hold (about 2.1 × 10^9), so use a 64-bit integer type: long long in C++, long in Java (Python needs nothing special).
Input
A single integer N.
Output
Print the number of good digit strings of length N modulo 1000000007.
Constraints
1 <= N <= 10^15
Example input
1
Example output
5
Explanation
For N = 1 the good strings are 0, 2, 4, 6 and 8, so the answer is 5. For N = 4 it is 5 × 4 × 5 × 4 = 400.