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βNβ100100βAiββ.
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β=S100β.
Therefore, the answer is
βi=1Nβ100100βAiββ100β=100β
i=1βNβ100βAiβ100β=βi=1Nβ(100βAiβ)100N+1β.
We compute this value modulo MOD=1000000007:
100N+1β
(i=1βNβ(100βAiβ))β1(modMOD).
Since 0β€Aiβ<100, each 100βAiβ is between 1 and 100. Also, MOD is a prime greater than 100, so the denominator is never divisible by MOD. Hence, the modular inverse always exists.
The time complexity is O(N+logMOD).