atcoder#ARC064D. [ARC064F] Rotated Palindromes
[ARC064F] Rotated Palindromes
Score : points
Problem Statement
Takahashi and Aoki are going to together construct a sequence of integers.
First, Takahashi will provide a sequence of integers , satisfying all of the following conditions:
- The length of is .
- Each element in is an integer between and , inclusive.
- is a palindrome, that is, reversing the order of elements in will result in the same sequence as the original.
Then, Aoki will perform the following operation an arbitrary number of times:
- Move the first element in to the end of .
How many sequences can be obtained after this procedure, modulo ?
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the number of the sequences that can be obtained after the procedure, modulo .
4 2
6
The following six sequences can be obtained:
1 10
10
6 3
75
1000000000 1000000000
875699961