P29120 [洛谷] "EZEC-6" Jump Jump
提高
题目描述

Problem Background

Little A has recently become obsessed with the game "Jump Jump".

Problem Description

The rules of "Jump Jump" that Little A plays are as follows:

  1. Set a counter $\text{cnt}$ with an initial value of $2$.
  2. If you jump to the next square but do not land on its center, add $1$ point and reset $\text{cnt}$ to $2$.
  3. If you jump to the next square and land on its center, add $\text{cnt}$ points and double $\text{cnt}$.
  4. If the next square is a special square $x_i$ and you land on its center, add an additional $y_i$ points.
  5. The termination condition is either failing to jump to the next square or completing all the squares.

Given that there are $n$ squares, numbered from $1$ to $n$ (excluding the starting square).

The probability that Little A jumps to the next square but does not land on its center is $a\%$, the probability that he jumps to the next square and lands on its center is $b\%$, and the remaining $(100-a-b)\%$ is the probability of failing to jump to the next square.

Calculate his expected score modulo $10^9+7$.

Input Format

The first line contains three integers $n, a, b$.

The second line contains an integer $m$, representing the number of special squares.

The next $m$ lines each contain two integers $x, y$, representing the number of each special square and its additional points, ensuring that $x$ is unique.

Output Format

An integer representing the expected score.

Sample Input and Output

Input Sample #1

3 0 100
0

Output Sample #1

14

Input Sample #2

3 100 0
0

Output Sample #2

3

Input Sample #3

3 0 0
0

Output Sample #3

0

Input Sample #4

3 0 100
3
1 10
2 10
3 10

Output Sample #4

44

Input Sample #5

114 5 14
3
14 15
92 65
100 100

Output Sample #5

190259152

Notes

[Sample 1 Explanation]

Little A always jumps to the next square and lands on its center, the expected score is $2+4+8=14$ points.

[Sample 2 Explanation]

Little A always jumps to the next square but does not land on its center, the expected score is $1+1+1=3$ points.

[Sample 3 Explanation]

Little A cannot jump to the next square, the expected score is $0$ points.

[Sample 4 Explanation]

Little A always jumps to the next square and lands on its center, the expected score is $2+10+4+10+8+10=44$ points.

[Data Range and Constraints]

This problem uses bundled testing.

The table below indicates no special restrictions where a slash is used.

Subtask Points $n$ $a$ $b$ $m$
$1$ $1$ $=1$ $=50$ $=50$ /
$2$ $9$ $\le 20$ / / $=0$
$3$ $10$ $\le 20$ / / /
$4$ $10$ $\le 10^5$ / / $=0$
$5$ $20$ $\le 10^5$ / / /
$6$ $5$ / $=0$ $=100$ /
$7$ $5$ / $=100$ $=0$ /
$8$ $15$ / / / $=0$
$9$ $25$ / / / /

For $100\%$ of the data, $1\le n\le 10^{18}$, $0\le a,b,a+b\le 100$, $0\le m\le \min(n,10^5)$, $1\le x\le n$, $1\le y\le 100$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 0 100 0
样例输出
14