#P3396. 哈希冲突
哈希冲突
Description
B is very interested in hash collisions. He will give a sequence of positive integers .
Naturally, B will store these data into hash buckets. will be stored in the bucket . This creates many collisions.
B will give many pairs and , asking for the sum of numbers in bucket under modulus .
In addition, B may change at any time. Each change takes effect immediately.
It is guaranteed that .
Input Format
The first line contains two positive integers , , where is the length of the sequence, and is the number of operations by B.
The second line contains positive integers, representing the initial sequence.
Then lines follow. Each line starts with a character , followed by two integers , .
- If , query the sum of numbers in bucket under modulus .
- If , change to .
Output Format
For each query, output one positive integer as the answer.
10 5
1 2 3 4 5 6 7 8 9 10
A 2 1
C 1 20
A 3 1
C 5 1
A 5 0
25
41
11
Hint
Sample Explanation
A 2 1 has the answer 1+3+5+7+9=25.
A 3 1 has the answer 20+4+7+10=41.
A 5 0 has the answer 1+10=11.
Constraints
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
All testdata are valid, and .
Translated by ChatGPT 5
京公网安备 11011102002149号