#abc297h. [abc297_h]Diff Adjacent
[abc297_h]Diff Adjacent
Problem Statement
A positive-integer sequence is said to be splendid if no two adjacent elements are equal.
Find the sum, modulo , of the lengths of all splendid sequences whose elements have a sum of .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
Sample Output 1
8
There are four splendid sequences whose sum is : . Thus, the answer is the sum of their lengths: .
and also have a sum of but ineligible because their -st and -nd elements are the same.
Sample Input 2
297
Sample Output 2
475867236
Sample Input 3
123456
Sample Output 3
771773807