QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100

#7892. Light Ray

统计

When a beam of light hits a layer of glass, a certain percentage of the light passes through the glass, a certain percentage is reflected back, and the remaining light is absorbed by the glass.

Suppose that for any amount of light $x$, $x \times a_i\%$ of the light passes through the $i$-th layer, and $x \times b_i\%$ is reflected back.

Now, $n$ layers of glass are stacked together. If $1$ unit of light hits the first layer of glass, how many units of light will pass through all $n$ layers?

Input

The first line contains an integer $n$, the number of glass layers.

The next $n$ lines each contain two integers $a_i$ and $b_i$, representing the percentage of light that passes through and is reflected by the $i$-th layer, respectively.

Output

Output a single integer representing the amount of light that passes through all layers, modulo $10^9 + 7$.

It can be proven that the answer is always a rational number. If the answer is $a/b$ (where $a$ and $b$ are coprime positive integers), you should output an integer $x$ such that $a \equiv bx \pmod{10^9 + 7}$.

Examples

Input 1

2
50 20
80 5

Output 1

858585865

Note 1

As shown in the figure, light enters from the top left. $0.5$ units of light pass through the first layer, and $0.2$ units are reflected back. Of the $0.5$ units, $0.4$ units pass through the second layer, and $0.025$ units are reflected back. Of the $0.025$ units, $0.0125$ units pass through the first layer, and $0.005$ units are reflected back. Of the $0.005$ units, $0.004$ units pass through the second layer... Thus, the total amount of light passing through both layers is $0.40404... = \frac{40}{99}$. Modulo $10^9+7$, this is equal to $858585865$.

Input 2

3
1 2
3 4
5 6

Output 2

843334849

Subtasks

For $5\%$ of the data, $n=1$.

For $20\%$ of the data, $n\le 2$.

For $30\%$ of the data, $n\le 3$.

For $50\%$ of the data, $n\le 100$.

For $70\%$ of the data, $n\le 3000$.

For $100\%$ of the data:

  • $1\le n\le 5\times 10^5$
  • $1\le a_i \le 100$
  • $0\le b_i \le 99$
  • $1\le a_i+b_i \le 100$
  • Each pair of $a_i$ and $b_i$ is generated randomly among integers satisfying the above constraints.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.