P23128 [AtCoder] [ARC034D] Inflation Game
提高+
题目描述

Problem Description

There are $ A + B + C $ cards. Among them, $ A $ cards each have one integer written in red ink, another $ B $ cards each have one integer written in blue ink, and the remaining $ C $ cards each have the word "Yutanpo" written on them. Takahashi plays a game using these cards following the steps below:

    1. Gather all $ A + B + C $ cards, shuffle them without bias, and place them on the table to form a deck.
    1. Set Takahashi's score to $ 0 $.
    1. Draw the top card from the deck.
  • 3-A. If the drawn card has an integer written in red ink, let that integer be $ a $ and increase Takahashi's score by $ a $.
  • 3-B. If the drawn card has an integer written in blue ink, let that integer be $ b $ and multiply Takahashi's score by $ b $.
  • 3-C. If the drawn card has "Yutanpo" written on it, the game is over. Takahashi's score at that point is his final score, and the game ends (step 4 is not performed).

    1. Discard the drawn card and repeat step 3.

Calculate the expected value of Takahashi's final score.

Input Format

The input is given from the standard input in the following format:

$ A $ $ B $ $ C $ $ a_1 $ $ a_2 $ .. $ a_A $ $ b_1 $ $ b_2 $ .. $ b_B $

  • The first line contains three integers $ A, B, C $ ($ 1 ≦ A, B, C ≦ 50 $), separated by spaces. These represent the number of cards with integers written in red ink, the number of cards with integers written in blue ink, and the number of cards with "Yutanpo" written on them, respectively. (Since $ C ≧ 1 $, the game always ends by step 3-C in the problem statement.)
  • The second line contains $ A $ integers $ a_1, a_2, ..., a_A $ ($ 1 ≦ a_i ≦ 100 $ for each $ i $ from $ 1 $ to $ A $), separated by spaces. These are the integers written on the $ A $ cards with red ink.
  • The third line contains $ B $ integers $ b_1, b_2, ..., b_B $ ($ 1 ≦ b_i ≦ 100 $ for each $ i $ from $ 1 $ to $ B $), separated by spaces. These are the integers written on the $ B $ cards with blue ink.

Output Format

Output the expected value of Takahashi's final score on the first line. The answer will be considered correct if the absolute or relative error between your output and the judge's output is at most $ 10^{-6} $. You may output in exponential notation.

Do not forget the newline at the end of the output.

Sample Input and Output

Sample Input #1

1 1 1
10
2

Sample Output #1

6.666666666666666667

Sample Input #2

4 1 1
1 1 1 3
2

Sample Output #2

4

Sample Input #3

7 2 2
1 1 1 1 5 5 5
5 5

Sample Output #3

29.13333333333333333

Sample Input #4

20 8 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8

Sample Output #4

19030.73484848484849

Sample Input #5

15 15 1
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100

Sample Output #5

5.626676749671402077e+030

Notes/Hints

Partial Points

This problem has partial points.

  • $ 5 $ points for test cases where $ 1 ≦ A, B, C ≦ 3 $.
  • Another $ 15 $ points for test cases where $ 1 ≦ A, B, C ≦ 8 $.
  • Another $ 20 $ points for test cases where $ 1 ≦ A, C ≦ 50 $, $ 1 ≦ B ≦ 8 $.

Sample Explanation 1

There are $ 3 $ cards in total: one with $ 10 $ written in red ink, one with $ 2 $ written in blue ink, and one with "Yutanpo". These $ 3 $ cards are shuffled without bias to form the deck. If the cards are arranged in the order "red, blue, Yutanpo" from the top, the final score is $ (0 + 10) × 2 = 20 $, and the probability of this order is $ 1/6 $. If the order is "red, Yutanpo, blue" or "blue, red, Yutanpo", the final score is $ 0 + 10 $ or $ 0 × 2 + 10 $, both resulting in $ 10 $, with a combined probability of $ 1/6 + 1/6 = 2/6 $. For other orders, the final score is $ 0 $. Therefore, the expected value of the final score is $ 20 × 1/6 + 10 × 2/6 = 20/3 $.

Sample Explanation 5

Output in exponential notation is acceptable.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1 1 10 2
样例输出
6.666666666666666667