bzoj#P3853. GCD Array
GCD Array
Description
Teacher Mai finds that many problems about arithmetic function can be reduced to the following problem:
Maintain an array a with index from to . There are two kinds of operations:
- Add to for every that .
- Query Sigma ()
Input
There are multiple test cases, terminated by a line "0 0".
For each test case, the first line contains two integers , , indicating the length of the array and the number of the operations.
In following Q lines, each line indicates an operation, and the format is " " or " " .
Output
For each case, output "Case #k:" first, where is the case number counting from .
Then output the answer to each query.
6 4
1 4 1 2
2 5
1 3 3 3
2 3
0 0
Case #1:
6
7