Card Drawing
InterviewTime limit1sMemory limit1024 MB
Given N cards with values, count the nonempty subsets of cards whose values are all distinct, modulo 10^9+7.
- Level
Medium4 of 10
- Topics
- Hash map, Combinatorics
- Solved
- No attempts yet
Problem
Leaf is playing a card drawing game. There are cards in a row, and each card has one positive integer written on it. The game proceeds as follows.
- Going from the 1st card to the th card in order, decide whether to draw each card. Each draw is independent.
- If no card was drawn, repeat the drawing process.
- If all integers on the drawn cards are different, the player wins.
Assuming Leaf draws each card with probability exactly , find the probability that Leaf wins.
Input
The first line contains .
The second line contains integers . The integer on the -th card is .
Output
Print the remainder of divided by on the first line. It can be proven that is always an integer.