Under construction

Still being built. Things may change

Dinner Bet

Time limit2sMemory limit512 MB

Summary
Given N balls, D drawn per round, and two size-C cards, find the expected number of rounds until one player completes their card.
Level

Medium7 of 10

Topics
Probability, Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

Cesar and Raul like betting and good food. They want to try a new fancy restaurant, so they agreed to play a game and let the loser pay for dinner.

A box holds NN balls, and each ball carries a distinct number between 11 and NN. The game runs by these rules.

  • At the start, each person picks CC distinct numbers between 11 and NN and writes them on his own card.
  • In each round, DD balls are drawn from the box. Every choice of DD balls is equally likely. Cesar and Raul mark the drawn numbers that appear on their own cards. The DD balls then go back into the box.
  • The game stops in the round where a player has marked every number on his card, and that player wins. If both players finish in the same round, the game is a draw and they split the dinner.

You are given the number of balls NN, the number of balls drawn each round DD, the card size CC, and the numbers the two players wrote down. Find the expected number of rounds the game lasts.

Input

The first line contains three space separated integers NN, DD, and CC. The second line contains the CC numbers Cesar wrote down, and the third line contains the CC numbers Raul wrote down, both space separated. The CC numbers on one line are distinct.

Output

Print the expected number of rounds the game lasts on one line, rounded to five digits after the decimal point.

Constraints

  • 1≤N≤501 \le N \le 50: the number of balls in the box
  • 1≤D≤min⁡(10,N)1 \le D \le \min(10, N): the number of balls drawn each round
  • 1≤C≤min⁡(10,N)1 \le C \le \min(10, N): the card size
  • Every number written on a card is between 11 and NN, and the numbers on one card are distinct.

Examples2

  1. Example 1

    Input
    2 1 1
    1
    2
    
    Expected output
    1.00000
    
  2. Example 2

    Input
    30 5 10
    2 3 5 7 11 13 17 19 23 29
    20 18 16 14 12 10 8 6 4 2
    
    Expected output
    13.30378