#SGM0000032. Bội số của 3 (Multiples of 3)
Bội số của 3 (Multiples of 3)
Multiples of 3
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
An array of values starts at zero. Each update increments a range; each query counts values divisible by 3.
Input
The first line contains . Each following line is type a b, using zero-based indices.
0 a b: increment every value in by 1.1 a b: count values in that are divisible by 3.
Output
Print the answer to each type 1 query.
Subtasks
- 20 points: .
- 30 points: .
- 50 points: , .
Examples
Input
4 7
1 0 3
0 1 2
0 1 3
1 0 0
0 0 3
1 3 3
1 0 3
Output
4
1
0
2
Explanation
Initially all four values are 0, so the first answer is 4. Range increments rotate residues modulo 3; the remaining query answers are 1, 0, and 2.