#P15878. [ICPC 2026 NAC] Draw Your Deck

[ICPC 2026 NAC] Draw Your Deck

Description

You are playing a single-player game with a deck of cards. The deck has NN cards, each with an integer between 00 and KK written on it. You shuffle the deck and draw a card, which forms your starting hand. You then play the game by repeatedly choosing and discarding a card from your hand. Each time you do so, you draw as many cards from the top of the deck into your hand as the integer written on the card you just discarded. (If there are not enough cards left in the deck, you draw them all.) You win if you draw all of the cards from the deck and you lose if you run out of cards in your hand when there are still cards left in the deck. Given the contents of the deck, and assuming that all possible shuffles of the deck are equally likely and that you play optimally, what is the probability you win the game?

Input Format

The first line of input contains two space-separated integers NN and KK, where NN (1N1500)(1 \leq N \leq 1500) is the number of cards in the deck and KK (0K3)(0 \leq K \leq 3) is the largest integer written on any of the cards.

The second line contains K+1K+1 space-separated integers aia_i (0aiN)(0 \leq a_i \leq N), starting at i=0i=0: the number of cards in the deck with the integer ii written on them. It is guaranteed that aK>0a_K > 0 and that the sum of all of the aia_i is NN.

Output Format

Print a real number: the probability that you win if you play optimally. Your answer will be accepted if it differs from the judge solution by an absolute error of at most 10610^{-6}.

4 2
2 0 2
0.3333333333333333
5 1
3 2
0.0