DOJ logoDOJ
Problems
Recently added problemsSaved problems
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Call for TasksLoginRegister
DOJ logoDOJ

Community online judge with OI-style subtask scoring, Elo ratings, and Discord-backed certification.

Problems
ProblemsCategories
Community
ContestsRankingBoardNoticesHost an external contestGuide
Account
LoginRegisterJudge Status
Policy
Terms of ServiceDLC RulesPrivacyAPI documentationLanguage runtimesContest rank rewardsRating and performance
© 2026 DOJ
All rights reserved
Editorial

Reflected Light

Back to problem

Editorial

Suppose an amount xxx of light is emitted upward from the ground.

The fraction of light that passes through the iii-th layer is

100−Ai100.\frac{100-A_i}{100}.100100−Ai​​.

Therefore, if SSS is the fraction of light that passes through all layers and escapes into space, then

S=∏i=1N100−Ai100.S = \prod_{i=1}^{N} \frac{100-A_i}{100}.S=i=1∏N​100100−

Thus, from an emitted amount xxx, the amount SxSxSx escapes and the remaining amount (1−S)x(1-S)x(1−S)x eventually returns to the ground.

The initial amount reaching the ground is 100100100. Since the fraction returning to the ground is always 1−S1-S1−S, the total amount reaching the ground is the geometric series

100+100(1−S)+100(1−S)2+⋯ .100 + 100(1-S) + 100(1-S)^2 + \cdots.100+100(1−S)+100(1−S)2+⋯

Its sum is

1001−(1−S)=100S.\frac{100}{1-(1-S)} = \frac{100}{S}.1−(1−S)100​=S

Therefore, the answer is

100∏i=1N100−Ai100=100⋅∏i=1N100100−Ai=100N+1∏i=1N(100−Ai).\frac{100}{\prod_{i=1}^{N} \frac{100-A_i}{100}} = 100 \cdot \prod_{i=1}^{N} \frac{100}{100-A_i} = \frac{100^{N+1}}{\prod_{i=1}^{N}(100-A_i)}.∏i=1

We compute this value modulo MOD=1 000 000 007MOD = 1\,000\,000\,007MOD=1000000007:

100N+1⋅(∏i=1N(100−Ai))−1(modMOD).100^{N+1} \cdot \left(\prod_{i=1}^{N}(100-A_i)\right)^{-1} \pmod{MOD}.100N+1⋅(i=1

Since 0≤Ai<1000 \le A_i < 1000≤Ai​<100, each 100−Ai100-A_i100−Ai​ is between and . Also, is a prime greater than , so the denominator is never divisible by . Hence, the modular inverse always exists.

The time complexity is O(N+log⁡MOD)O(N+\log MOD)O(N+logMOD).

Ai​
​
.
.
100
​
.
N
​
100100−Ai​​
100
​
=
100⋅
i=1∏N​100−Ai​100​=
∏i=1N​(100−Ai​)100N+1​.
∏
N
​
(
100
−
Ai​
)
)
−1
(modMOD).
111
100100100
MODMODMOD
100100100
MODMODMOD