QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#7892. 光線

Statistiques

當一束光打到一層玻璃上時,有一定比例的光會穿過這層玻璃,一定比例的光會被反射回去,剩下的光被玻璃吸收。

設對於任意 $x$,有 $x\times a_i\%$ 單位的光會穿過它,有 $x\times b_i\%$ 的會被反射回去。

現在 $n$ 層玻璃疊在一起,有 $1$ 單位的光打到第 $1$ 層玻璃上,那麼有多少單位的光能穿過所有 $n$ 層玻璃呢?

輸入格式

第一行包含一個整數 $n$,表示玻璃的層數。

接下來 $n$ 行,每行包含兩個整數 $a_i$ 和 $b_i$,分別表示第 $i$ 層玻璃的穿透率百分比與反射率百分比。

輸出格式

輸出一行一個整數,表示穿透所有玻璃的光對 $10^9 + 7$ 取模的結果。

可以證明,答案一定為有理數。設答案為 $a/b$($a$ 和 $b$ 是互質的正整數),你輸出的答案為 $x$,你需要保證 $a\equiv bx \pmod {10^9 + 7}$。

範例

範例輸入 1

2
50 20
80 5

範例輸出 1

858585865

說明 1

如圖,光線從左上角打進來,有 $0.5$ 單位的光穿過第 $1$ 層玻璃,有 $0.2$ 單位的光被反射回去。這 $0.5$ 單位的光有 $0.4$ 單位穿過第 $2$ 層玻璃,有 $0.025$ 單位的光被反射回去。這 $0.025$ 單位的光有 $0.0125$ 單位穿過第 $1$ 層玻璃,有 $0.005$ 單位的光被反射回去。這 $0.005$ 單位的光有 $0.004$ 單位穿過第 $2$ 層玻璃……於是,穿過兩層玻璃的光一共有 $0.40404... = \frac{40}{99}$ 單位。在模 $10^9+7$ 意義下等於 $858585865$。

範例輸入 2

3
1 2
3 4
5 6

範例輸出 2

843334849

子任務

對於 $5\%$ 的資料,保證 $n=1$。

對於 $20\%$ 的資料,保證 $n\le 2$。

對於 $30\%$ 的資料,保證 $n\le 3$。

對於 $50\%$ 的資料,保證 $n\le 100$。

對於 $70\%$ 的資料,保證 $n\le 3000$。

對於 $100\%$ 的資料:

  • $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$
  • 每組 $a_i$ 和 $b_i$ 在滿足上述限制的整數中隨機生成。

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.