Secret of the Sequence (Hard)
InterviewTime limit1sMemory limit1024 MB
Given a sequence where a_2i and a_2i+1 are linear functions of a_i, find the sum of the first 2^k-1 terms modulo 1e9+7.
- Level
Medium5 of 10
- Topics
- Divide and conquer, Recursion, Math
- Solved
- No attempts yet
Problem
There is a sequence of length that satisfies the following conditions.
Let . Print the remainder of divided by .
Input
The first line contains a positive integer .
The second line contains positive integers , separated by spaces.
The third line contains a positive integer .
Output
Print the remainder of divided by on the first line.
Constraints
Hint
Intermediate values can exceed the range of the C/C++ int type, so using long long is recommended.