atcoder#ABC241E. [ABC241E] Putting Candies
[ABC241E] Putting Candies
Score : points
Problem Statement
You are given a sequence of length . There is an initially empty dish. Takahashi is going to repeat the following operation times.
- Let be the number of candies on the dish. He puts more candies on the dish. Here, denotes the remainder when is divided by .
Find how many candies are on the dish after the operations.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
5 3
2 1 6 3 1
11
The number of candies on the dish transitions as follows.
- In the -st operation, we have , so more candies will be put on the dish.
- In the -nd operation, we have , so more candies will be put on the dish.
- In the -rd operation, we have , so more candies will be put on the dish.
Thus, after the operations, there will be candies on the dish. Note that you must not print the remainder divided by .
10 1000000000000
260522 914575 436426 979445 648772 690081 933447 190629 703497 47202
826617499998784056
The answer may not fit into a -bit integer type.