当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7085:Pty loves SegmentTree

题目描述
Pty loves data structures, especially segmenttree.

Pty thinks that the segmenttree satifies each point to represent the interval [l,r]. The point with l = r is called a leaf. The other point select mid in [l,r-1] and take [l,mid] and [mid + 1,r] as son.

Pty gives each point in the tree a value. For the leaves, the value is 1; For the point whose right son interval size is k, the value is A; The other point’s value is B. Pty denotes the value of the tree as the value product of all points.

Pty denotes $f_n$ as the sum of all the tree that the interval of the root is [1,n]. He thinks that the two trees are different if and only if the shape is different.

Now Pty has Q queries, for each query Pty wants to know the value of $\sum_{i=L}^R f_i^2$

Noticed that the answer is large, you only need to find the answer after modulo 998244353.
输入解释
A positive integer T in the first line indicates the number of test.

For each test,the first line contains four integers Q,k,A,B.

For the next Q lines, each line contains two intergers L,R.


$1\le T\le 5, 1\le Q \le 5 \times 10^4, 0 \le A,B < 998244353, 1 \le L \le R \le 10^7, 1 \le k \le 10^7$
输出解释
For each query, print the answer.
输入样例
1
1 1 3 1
4 4
输出样例
3249
来自杭电HDUOJ的附加信息
Hint There are 5 different trees, 1 with a value of 3,3 with a value of 9,1 with a value of 27. The sum is 3*1 + 9*3 + 27*1 = 57,57*57 = 3249

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7085

最后修改于 2021-10-23T19:11:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
30000/15000MS(Java/Others) 524288/524288K(Java/Others)