#P4140. [清华集训 2014] 奇数国

    ID: 3076 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学2014线段树树状数组素数判断,质数,筛法逆元清华集训

[清华集训 2014] 奇数国

Description

On a beautiful continent there are 100000100\,000 countries, numbered from 11 to 100000100\,000. The economy is prosperous, there are countless accounting offices, and each country has one bank.

When a big company's leader opened accounts in these 100000100\,000 banks, he deposited 33 coins in each. He is very stingy, so he will from time to time send his lackey GFS to tally deposits in some banks or ask GFS to change the deposit of a certain bank.

In this land, the summation operation on wealth corresponds to our multiplication. That is, the total deposit when the leader opened accounts is 31000003^{100000}. The banknote denominations issued here are the smallest 6060 primes (p1=2,p2=3,,p60=281p_1=2, p_2=3, \ldots, p_{60}=281). Anyone’s wealth can only be represented using these 6060 basic denominations. Suppose a person’s wealth is fortunefortune (a positive integer), then $fortune = p_1^{k_1} \times p_2^{k_2} \times \ldots p_{60}^{k_{60}}$.

The leader tends to take deposits from a consecutive range of banks to one accounting office to tally. To avoid GFS colluding with an accounting office, he will not choose the same accounting office every time. After following the leader for many years, GFS has figured out the rule: if the leader chooses to tally the wealth of banks numbered in [a,b][a,b], he will first “sum” (i.e., multiply) the wealth over [a,b][a,b] (denoted as productproduct), and then pick an accounting office whose number is in [1,product][1, product] to tally the deposits, both to verify his own computation and to check whether the accounting office and GFS are colluding. GFS noticed that if an accounting office’s number numbernumber is in conflict with productproduct, the leader will never choose that office.

What does it mean to be not in conflict with productproduct? If there exist integers x,yx, y such that number×x+product×y=1number \times x + product \times y = 1, then we say numbernumber is not in conflict with productproduct, i.e., that accounting office may be chosen by the leader. When the leader makes a lot more money, he will change the deposit in some bank; thus the productproduct computed for the same interval at different times may differ. Moreover, the leader will not let the deposit in any single bank exceed 10610^6.

Now that GFS knows in advance the leader’s plan for tallying and changing deposits, he wants you to tell him, for each tally, how many accounting offices the leader can choose from. Since this number can be very large, GFS only wants the answer modulo 1996199319\,961\,993.

Input Format

The first line contains an integer xx denoting the total number of tally and update operations.

Then follow xx lines, each with 33 integers ai,bi,cia_i, b_i, c_i. If ai=0a_i = 0, this record is a tally plan: the leader will tally deposits of banks from bib_i to cic_i, and you need to compute the answer GFS wants for this record. If ai=1a_i = 1, this record is an update: you should change the deposit of bank bib_i to cic_i, and you do not need to output anything for this record.

Output Format

For each query, output a single integer per line denoting the answer.

6
0 1 3
1 1 5
0 1 3
1 1 7
0 1 3
0 2 3
18
24
36
6


Hint

Sample Explanation

  • Initially, each country’s deposit is 33.
  • The productproduct for 11 to 33 is 2727. In [1,27][1,27], there are 1818 numbers not in conflict with 2727.
  • The deposit of 11 becomes 55.
  • The productproduct for 11 to 33 is 4545. In [1,45][1,45], there are 2424 numbers not in conflict with 4545.
  • The deposit of 11 becomes 77.
  • The productproduct for 11 to 33 is 6363. In [1,63][1,63], there are 3636 numbers not in conflict with 6363.
  • The productproduct for 22 to 33 is 99. In [1,9][1,9], there are 66 numbers not in conflict with 99.

Constraints

All testdata satisfy: x1x \geq 1, cibi0c_i - b_i \geq 0.

Subtask ID Score xx \leq cibic_i - b_i \leq Special Property
11 2020 10410^4 100100 Yes
22 3030 5×1045 \times 10^4 10410^4 No
33 5050 10510^5

Special property means: all product1018product \leq 10^{18}.

Translated by ChatGPT 5