Company: Zeta_4August
Difficulty: medium
Expected Supply Problem Description A bulb factory packs its bulbs into boxes and ships them to suppliers every month. Every box contains exactly m bulbs. The factory produces n boxes full of bulbs every month. A box is sent for supply only if the box itself is not defective and none of its m bulbs is defective. The probability that a box is defective is p = a / b . The probability that a bulb is defective is q = c / d . All of these defects happen independently of each other. (inferred -- the source does not say so; it is the only reading that makes the expected value well defined.) Find the expected number of boxes the factory sends for supply in one month. This expected value is a fraction P / Q . Print it as P * Q^(-1) modulo 10^9 + 7 , where Q^(-1) is the modular inverse of Q modulo 10^9 + 7 . (inferred -- the source asks for "a single integer" but does not say how a fractional expected value becomes one. Its function returns a 32-bit int while n can be 10^18 , so the plain value