| TheForces Round #24 (DIV3-Forces) |
|---|
| Finished |
This is the hard version of the problem. The only difference between the two versions are the constraints on $$$l$$$ and $$$r$$$.
There is a flow network with $$$n$$$ vertices, numbered from $$$1$$$ to $$$n$$$.The source node is vertex $$$1$$$, and the sink node is vertex $$$n$$$.
The following condition holds:
Calculate the sum of the maximum flow of the flow network, in all $$$n \in [l,r]$$$, mod $$$998244353$$$.
i.e) Let's call the maximum flow of $$$n = i$$$ by $$$flow(i)$$$, Then you should calculate the $$$ \left( \sum_{i=l}^r flow(i) \right)\mod 998244353 $$$.
The first line of the input contains an integer $$$t (1 \le t \le 100)$$$ — the number of test cases.
Then follow the descriptions of the test cases.
Each test case consists of one line, contains two integers $$$l$$$ and $$$r$$$ $$$(2 \le l \le r \le 10^{14})$$$ — described in statement.
The sum of $$$r$$$ over all test cases does not exceed $$$10^{14}$$$.
Print out $$$t$$$ lines, each of which is the answer to the corresponding test case.
32 36 910 15
5 41 99
| Name |
|---|


