atcoder#ARC071D. [ARC071F] Infinite Sequence
[ARC071F] Infinite Sequence
Score : points
Problem Statement
How many infinite sequences consisting of {} satisfy the following conditions?
- The -th and subsequent elements are all equal. That is, if , .
- For every integer , the elements immediately following the -th element are all equal. That is, if , .
Find the count modulo .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print how many sequences satisfy the conditions, modulo .
2
4
The four sequences that satisfy the conditions are:
654321
968545283