atcoder#ARC135F. [ARC135F] Delete 1, 4, 7, ...
[ARC135F] Delete 1, 4, 7, ...
Score : points
Problem Statement
You are given an integer . On an integer sequence , let us do the operation below exactly times.
- Let be the current number of terms in . For all such that and , delete the -th term of , simultaneously.
Find the sum of the terms of after operations, modulo .
Constraints
Input
Input is given from Standard Input from the following format:
Output
Print the sum of the terms of after operations, modulo .
10 2
25
- Initially, we have .
- After the first operation, we have .
- After the second operation, we have .
- The sum of the terms here is .
10 10
0
- After the second operation, we have (same as Sample Input 1).
- After the third operation, we have .
- After the fourth operation, we have .
- After the fifth operation, is empty.
- In the sixth and subsequent operations, remains empty, where the sum of the terms is .
10000 10
862816