#524. 余数问题
余数问题
题目描述
You are given an array consisting of integers (numbered from to ). Initially all elements of are zero.
You have to process two types of queries to this array:
- — increase by ;
- — compute , where is the set of all integers from to which have remainder modulo . Can you process all the queries?
题意
一个长度为 的数组,初始为空,支持两种操作。
操作 , 表示将 增加 。
操作 ,,表示统计所有下标模 为 的数的和,一共有 次操作。
输入格式
The first line contains one integer — the number of queries.
Then lines follow, each describing a query. The -th line contains three integers , and . If , then it is a query of the first type, , and . If , then it it a query of the second type, , and .
It is guaranteed that there will be at least one query of type .
输出格式
For each query of type print one integer — the answer to it.
样例
样例输入
5
1 3 4
2 3 0
2 4 3
1 4 -4
2 1 0
样例输出
4
4
0