#SGM0000059. Tổng và thay thế (SUM and REPLACE)
Tổng và thay thế (SUM and REPLACE)
SUM and REPLACE
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Let be the number of positive divisors of positive integer . Given , process operations:
1 l r: for every , set .2 l r: print the sum of the elements in .
Input
The first line contains . The second line contains the array. Each of the next lines contains t l r, where t=1 is REPLACE and t=2 is SUM.
Output
For every type-2 operation, print the range sum on its own line.
Subtasks
-
Subtask 1 (20%): n,m≤30; all other conditions are unchanged.
-
Subtask 2 (30%): n,m≤3000; all other conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
there is at least one type-2 query
Examples
Input
7 6
6 4 1 10 3 2 4
2 1 7
2 4 5
1 3 5
2 4 4
1 5 7
2 1 7
Output
30
13
4
22
Explanation
Initially the whole-array sum is 30. Replacing positions 3..5 by their divisor counts changes 1,10,3 into 1,4,2; therefore the single-position sum at 4 is 4.