CF1295F.Good Contest
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared n problems; and since the platform is very popular, 998244351 coder from all over the world is going to solve them.
For each problem, the authors estimated the number of people who would solve it: for the i-th problem, the number of accepted solutions will be between li and ri, inclusive.
The creator of ForceCoders uses different criteria to determine if the contest is good or bad. One of these criteria is the number of inversions in the problem order. An inversion is a pair of problems (x,y) such that x is located earlier in the contest (x<y), but the number of accepted solutions for y is strictly greater.
Obviously, both the creator of ForceCoders and the authors of the contest want the contest to be good. Now they want to calculate the probability that there will be no inversions in the problem order, assuming that for each problem i, any integral number of accepted solutions for it (between li and ri) is equally probable, and all these numbers are independent.
一场在线编程竞赛即将在 ForceCoders 这一大型编程竞赛平台上举行。出题人共准备了 n 道题目;由于该平台非常受欢迎,全球将有 998244351 名程序员参与解题。
对于每道题目,出题人均预估了其通过人数:第 i 道题的通过人数将在 li 到 ri 之间(含端点)。
ForceCoders 平台的创始人采用多种标准来评判一场竞赛是否优秀,其中一条标准便是题目顺序中的“逆序对”数量。一个逆序对是指一对题目 (x,y),满足 x 在比赛中排在 y 之前(即 x<y),但 y 的通过人数严格大于 x 的通过人数。
显然,ForceCoders 平台创始人与竞赛出题人都希望这场竞赛是优秀的。现在,他们希望计算题目顺序中不出现任何逆序对的概率。假设对于每道题 i,其通过人数在区间 [li,ri] 内的任意整数值均等可能,且各题的通过人数相互独立。
输入格式
The first line contains one integer n (2≤n≤50) — the number of problems in the contest.
Then n lines follow, the i-th line contains two integers li and ri (0≤li≤ri≤998244351) — the minimum and maximum number of accepted solutions for the i-th problem, respectively.
第一行包含一个整数 n(2≤n≤50)—— 表示比赛中的题目数量。
接下来有 n 行,其中第 i 行包含两个整数 li 和 ri(0≤li≤ri≤998244351)—— 分别表示第 i 题的通过人数下限与上限。
输出格式
The probability that there will be no inversions in the contest can be expressed as an irreducible fraction yx, where y is coprime with 998244353. Print one integer — the value of xy−1, taken modulo 998244353, where y−1 is an integer such that yy−1≡1 (mod 998244353).
比赛中不出现逆序对的概率可以表示为最简分数 yx,其中 y 与 998244353 互质。请输出一个整数 —— xy−1mod998244353 的值,这里 y−1 是满足 yy−1≡1(mod998244353) 的整数。
输入输出样例
输入#1
3 1 2 1 2 1 2
输出#1
499122177
输入#2
2 42 1337 13 420
输出#2
578894053
输入#3
2 1 1 0 0
输出#3
1
输入#4
2 1 1 1 1
输出#4
1
说明/提示
The real answer in the first test is 21.
第一个测试用例的正确答案是 21。
输入解题思路,AI测评打分。不知道怎么写?