QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100

#4346. rpfrdtzls

Statistics

Given $n, m, A$, maintain a sequence of sequences $a_1, \dots, a_n$, where initially each $a_i$ contains a single element $A$.

There are $m$ operations in total:

  • Modification: Given $l, r, x$, for all $l \le i \le r$, insert the element $x$ at the beginning of the sequence $a_i$.
  • Query: Given $l, r$, query $\sum_{i=l}^r F(a_i, A)$.

Where $F((x_1, \dots, x_n), 0) = 0$;

For $k > 0$, $F((x_1, \dots, x_n), k) = F\left((x_2, \dots, x_n), \left\lfloor \frac{k}{x_1} \right\rfloor\right) + 1$.

Input

The first line contains three integers $n, m, A$.

The next $m$ lines each contain either 1 l r x representing a modification operation, or 2 l r representing a query operation.

Output

For each query operation, output one line representing the answer.

Examples

Input 1

5 20 10
1 4 4 166348285
2 2 5
2 1 5
1 1 2 10
1 4 4 3
1 4 5 6
2 5 5
1 5 5 1
1 2 3 1
2 5 5
2 5 5
2 3 4
2 3 3
2 4 5
2 4 4
1 2 5 5
1 5 5 9
1 1 4 5
2 5 5
2 1 4

Output 1

4
5
2
3
3
4
2
5
2
2
8

Examples 2 ~ 5

See the provided files.

Subtasks

Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078

Note that bundled testing is used.

For $25\%$ of the data, $n, m \le 100$.

For $50\%$ of the data, $n, m \le 10^5$.

For another $25\%$ of the data, $x \ne 1$.

For $100\%$ of the data, $1 \le n, m \le 5 \times 10^5$, $1 \le A, x \le 10^9$, $1 \le l \le r \le n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.