A13219 | Good Contest
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $l_i$ and $r_i$ , 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 $l_i$ and $r_i$ ) is equally probable, and all these numbers are independent.
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 $l_i$ and $r_i$ , 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 $l_i$ and $r_i$ ) is equally probable, and all these numbers are independent.
输入格式
The first line contains one integer $n$ ( $2 \le n \le 50$ ) — the number of problems in the contest.
Then $n$ lines follow, the $i$ -th line contains two integers $l_i$ and $r_i$ ( $0 \le l_i \le r_i \le 998244351$ ) — the minimum and maximum number of accepted solutions for the $i$ -th problem, respectively.
Then $n$ lines follow, the $i$ -th line contains two integers $l_i$ and $r_i$ ( $0 \le l_i \le r_i \le 998244351$ ) — the minimum and maximum number of accepted solutions for the $i$ -th problem, respectively.
输出格式
The probability that there will be no inversions in the contest can be expressed as an irreducible fraction $\frac{x}{y}$ , 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} \equiv 1$ $(mod$ $998244353)$ .
输入输出样例
输入 #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 $\frac{1}{2}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted