Suppose an amount x of light is emitted upward from the ground.
The fraction of light that passes through the i-th layer is
100100−Ai.
Therefore, if S is the fraction of light that passes through all layers and escapes into space, then
S=i=1∏N100100−
Thus, from an emitted amount x, the amount Sx escapes and the remaining amount (1−S)x eventually returns to the ground.
The initial amount reaching the ground is 100. Since the fraction returning to the ground is always 1−S, the total amount reaching the ground is the geometric series
100+100(1−S)+100(1−S)2+⋯
Its sum is
1−(1−S)100=S
Therefore, the answer is
∏i=1
We compute this value modulo MOD=1000000007:
100N+1⋅(i=1
Since 0≤Ai<100, each 100−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+logMOD).