Cards
Time limit2sMemory limit512 MB
Find the probability that L random packs of N equally likely card types meet every demand D_i, output as a fraction mod 1e9+7.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Probability
- Solved
- No attempts yet
Problem
He started a new strategy card game. To get a card in this game you buy a card pack that holds exactly one card. You cannot see what is inside a pack before opening it. A pack holds one of the card types in the game, and every type is equally likely.
Collecting the cards is only part of the work. He also has to build decks. Number the cards through . To build every deck he wants, he needs at least copies of card . His goal is therefore to collect or more copies of card for every .
Money is the problem. Packs cost money and he does not have much, so he decided to buy only packs. Write a program that computes the probability that he reaches his goal after opening those packs.
Input
The first line contains two natural numbers and , separated by a space. They are the number of card types and the number of card packs he buys.
The second line contains integers , separated by spaces, where is how many copies of card he has to collect.
, ,
Output
Print the probability that he reaches his goal. For an exact check, write the answer as a reduced fraction and print instead. Here is the multiplicative inverse of modulo . The answer exists for every input this problem gives.