问题 A: Random Addition

内存限制:1024 MB 时间限制:5 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

链接:https://ac.nowcoder.com/acm/contest/57361/A
来源:牛客网
Daniel and sszcdjr are playing a game. The game is played on a sequence aaa of length nnn. Initially, all elements in aaa are equal to 000. They will do the following operations mmm times on it:

* Daniel selects one segment [li,ri][l_i,r_i][li,ri] (1≤l≤r≤n1\le l\le r\le n1lrn);
* Then, sszcdjr chooses a real number xxx such that 0≤x≤10\le x\le 10x1 \bf{uniformly at random};
* For all li≤j≤ril_i\le j\le r_ilijri, set aj:=aj+xa_j:=a_j+xaj:=aj+x.

However, sszcdjr thinks it is unfair for him. So he adds a rule: for any two segments [li,ri][l_i,r_i][li,ri] and [lj,rj][l_j,r_j][lj,rj] (i≠ji\ne ji=j), one of the following condition must holds:

* The two segments are completely disjoint. More formally, either li≤ri<lj≤rjl_i\le r_i<l_j\le r_jliri<ljrj or lj≤rj<li≤ril_j\le r_j<l_i\le r_iljrj<liri;
* One of the two segments are inside another. More formally, either li≤lj≤rj≤ril_i\le l_j\le r_j\le r_ililjrjri or lj≤li≤ri≤rjl_j\le l_i\le r_i\le r_jljlirirj.

Note that two segments can be exactly the same.

Let sss be the maximum number in aaa after the operations. zxx is crazy about probabilities, so he gives you ttt queries. In each query, he gives you two numbers PPP, QQQ, and asks you the probability that P≤s≤QP\le s\le QPsQ. You just need to tell him the answer modulo 998 244 353998~244~353998 244 353.

输入格式

The first line of input contains three integers nnn, mmm, ttt (1≤n≤1061\leq n\leq 10^61n106, 1≤m≤2001\leq m \leq 2001m200 1≤t≤5×1051\leq t\leq 5\times 10^51t5×105) --- the length of the sequence, the number of operations and the number of queries.
Then mmm lines follow, the iii-th line contains two integers lil_ili, rir_iri (1≤li≤ri≤n1\le l_i\le r_i\le n1lirin) --- the segment in the iii-th operation.
In the following ttt lines, each line contains two integers ppp, qqq (0≤p<q≤1070\le p<q\le 10^70p<q107) --- the two numbers piggy give you in the query are equal to P=p⋅10−6P=p\cdot 10^{-6}P=p106 and Q=q⋅10−6Q=q\cdot 10^{-6}Q=q106 .

输出格式

For each query print an integer --- the probability that P≤s≤QP\le s\le QPsQ, modulo 998 244 353998~244~353998 244 353.
Formally, let M=998244353M = 998\,244\,353M=998244353. It can be shown that the answer can be expressed as an irreducible fraction pq\frac{p}{q}qp, where ppp and qqq are integers and q≢0(modM)q \not \equiv 0 \pmod{M}q0(modM). Output the integer equal to p⋅q−1modMp \cdot q^{-1} \bmod Mpq1modM. In other words, output such an integer xxx that 0≤x<M0 \le x < M0x<M and x⋅q≡p(modM)x \cdot q \equiv p \pmod{M}xqp(modM).

输入样例 复制

6 3 5
1 6
2 3
4 5
0 1000000
1000000 2000000
200000 800000
0 1500000
114 514

输出样例 复制

332748118
665496236
143747187
540715692
586651392