CF1295F.Good Contest

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared nn problems; and since the platform is very popular, 998244351998244351 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 ii -th problem, the number of accepted solutions will be between lil_i and rir_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)(x, y) such that xx is located earlier in the contest ( x<yx < y ), but the number of accepted solutions for yy 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 ii , any integral number of accepted solutions for it (between lil_i and rir_i ) is equally probable, and all these numbers are independent.

输入格式

The first line contains one integer nn ( 2n502 \le n \le 50 ) — the number of problems in the contest.

Then nn lines follow, the ii -th line contains two integers lil_i and rir_i ( 0liri9982443510 \le l_i \le r_i \le 998244351 ) — the minimum and maximum number of accepted solutions for the ii -th problem, respectively.

输出格式

The probability that there will be no inversions in the contest can be expressed as an irreducible fraction xy\frac{x}{y} , where yy is coprime with 998244353998244353 . Print one integer — the value of xy1xy^{-1} , taken modulo 998244353998244353 , where y1y^{-1} is an integer such that yy11yy^{-1} \equiv 1 (mod(mod 998244353)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 12\frac{1}{2} .

首页