#P5444. [APIO2019] 奇怪装置
[APIO2019] 奇怪装置
Description
Archaeologists have discovered a strange device left behind by an ancient civilization. The device has two screens, which display two integers and .
After research, scientists reached the following conclusion: the device is a special clock. It starts counting the number of moments that have passed since some point in the past, but the creator displays in a strange way. If the number of moments that have passed since the device started measuring is , then it displays two integers: , and . Here is the floor function, which means the greatest integer less than or equal to .
Archaeologists further found that the screens cannot work all the time. In fact, the screens work normally only during continuous time intervals. The -th interval is from moment to moment . Now scientists want to know how many different pairs can be displayed while the device is working.
Two pairs and are different if and only if or .
Input Format
The first line contains three integers , , and . The next lines each contain two integers and , representing the -th time interval during which the device can work.
Output Format
Output one line containing one integer, the answer to the problem.
3 3 3
4 4
7 9
17 18
4
3 5 10
1 20
50 68
89 98
31
2 16 13
2 5
18 18
5
Hint
For the first sample, the device screens will display the following pairs.
There are four different pairs in total: .
For all data, $1 \leq n \leq 10^6,1 \leq A,B \leq 10^{18},0 \leq l_i \leq r_i \leq 10^{18}$.
Let and .
The detailed additional constraints and scores for subtasks are shown in the table below:
| Subtask | Additional Constraints | Score |
|---|---|---|
| 1 | 10 | |
| 2 | 5 | |
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | 20 | |
| 7 | ||
| 8 | No additional constraints. | 30 |
Translated by ChatGPT 5
京公网安备 11011102002149号