Determinants and GCD
Time limit2sMemory limit512 MB
For a tridiagonal matrix with a fixed pattern, let D(k) be its k-by-k determinant and compute the sum of gcd(D(i), D(N)) for i from 1 to N, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
The entries of the matrix are as follows.
- every other entry is 0
For example, when , is
1 1 0 0
-1 1 1 0
0 -1 1 1
0 0 -1 1
Let be the determinant of the matrix built by the same rule. Given , write a program that computes .
Input
The first line contains . ()
Output
Print modulo . The is computed from the actual determinant values, before any reduction modulo .