問題一覧 > 通常問題

No.907 Continuous Kadomatu

レベル : / AI推定難易度 : 2175 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 27
作問者 : pekempey / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 2900 / 自分の提出
問題文最終更新日: 2019-12-11 18:16:10
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 227 (順位表) の他の問題:

Problem Statement

Suppose a sequence of "real numbers" $a_1,\ldots,a_N$ of length $N$ is constructed by the following method. Find the probability that the constructed sequence is a Kadomatsu sequence.

  • Choose a "real number" between $A_i$ and $B_i$, inclusive, uniformly at random, and let it be $a_i$.

A sequence $a_1,\ldots,a_N$ is called a Kadomatsu sequence if $a_1 \le a_2 \ge a_3 \le a_4 \ge a_5 \le \cdots $. That is, the following holds for all $1 \le i \le N-1$.

  • If $i$ is odd, then $a_i \le a_{i+1}$.
  • If $i$ is even, then $a_i \ge a_{i+1}$.

Note that the constructed sequence is not an integer sequence but a "real sequence".

Input

$N$
$A_1\ B_1$
$\vdots$
$A_N\ B_N$

$3 \le N \le 200$
$1 \le A_i < B_i \le 10^9$
All inputs are integers.

Output

The answer can be expressed as an irreducible fraction $p/q$, so output $p\,q^{-1} \bmod{10^9+7}$. That is, output the smallest non-negative integer $x$ satisfying $xq \equiv p \pmod{10^9+7}$. In this problem, this value always exists.

Sample

Sample 1
Input
3
1 3
1 3
1 3
Output
333333336

The answer is $1/3$. This can be rephrased as the probability that the second value is the largest when three real numbers are randomly generated, which is $1/3$ by symmetry. Note that the constructed sequence is not an integer sequence but a "real sequence".

Sample 2
Input
3
1 2
2 3
1 2
Output
1

The answer is $1/1$.

Sample 3
Input
3
2 3
1 2
2 3
Output
0

The answer is $0/1$. The only possible Kadomatsu sequence is $2,2,2$, but the probability of it appearing is $0$.

Sample 4
Input
5
1 4
2 3
1 3
2 4
1 4
Output
715740746

The answer is $269/1080$.

Sample 5
Input
9
766526787 974319581
941243410 942612052
427056305 964028266
313356130 664522966
480128631 531723103
1626524 615851774
293907611 496577233
1955784 467846274
83687962 802560435
Output
175278186

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。