100 atcoder#ABC179E. [ABC179E] Sequence Sum
[ABC179E] Sequence Sum
Score : points
Problem Statement
Let us denote by the remainder of the Euclidean division of by .
Let be the sequence that is defined by the initial value and the recurrence relation . Find .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print .
6 2 1001
1369
The sequence begins Therefore, the answer is .
1000 2 16
6
The sequence begins Therefore, the answer is .
10000000000 10 99959
492443256176507