P26149 [AtCoder] [ARC033B] Metasyntactic Variables
普及-
题目描述

Problem Description

Strings like "foo", "bar", and "hoge" that are used as variable names without any particular meaning are called "metasyntactic variables".

Takahashi is currently researching metasyntactic variables. He has found that there are various types of metasyntactic variables and has assigned a number to each one he discovered. Takahashi read the source code of Ant and Bug, and listed the numbers of the metasyntactic variables appearing in each source code. To determine how similar the sets of metasyntactic variables used by Ant and Bug are, he decided to calculate the "Jaccard coefficient". If the set of metasyntactic variables appearing in Ant's source code is $ S_A $ and the set of metasyntactic variables appearing in Bug's source code is $ S_B $, the Jaccard coefficient of these sets can be calculated using the formula:

  • $ ||S_{A} ∩ S_{B}|| / ||S_{A} ∪ S_{B}|| $

Here, $ ||S|| $ represents the number of elements in set $ S $. In other words, it is:

  • "The number of elements that appear in both $ S_{A} $ and $ S_{B} $" / "The number of elements that appear in at least one of $ S_{A} $ or $ S_{B} $"

Input Format

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

$ N_A $ $ N_B $ $ A_1 $ $ A_2 $ ... $ A_{N_A} $ $ B_1 $ $ B_2 $ ... $ B_{N_B} $

  • The first line contains two integers $N_A\ (1 ≦ N_A ≦ 10^5)$ and $N_B\ (1 ≦ N_B ≦ 10^5)$ separated by a space. This indicates that $ N_A $ metasyntactic variables appear in Ant's source code and $ N_B $ metasyntactic variables appear in Bug's source code.
  • The second line contains $ N_A $ integers separated by spaces, representing the numbers of the metasyntactic variables that appear in Ant's source code. The $ i $-th integer $A_i\ (1 ≦ A_i ≦ 10^9)$ indicates that the $ A_i $-th metasyntactic variable appears in Ant's source code. It is guaranteed that $ A_p ≠ A_q $ when $ p ≠ q $.
  • The third line contains $ N_B $ integers separated by spaces, representing the numbers of the metasyntactic variables that appear in Bug's source code. The $ i $-th integer $B_i\ (1 ≦ B_i ≦ 10^9)$ indicates that the $ B_i $-th metasyntactic variable appears in Bug's source code. It is guaranteed that $ B_p ≠ B_q $ when $ p ≠ q $.

Output Format

Output the Jaccard coefficient of the sets of metasyntactic variables appearing in Ant's and Bug's source codes on a single line. You may output any number of decimal places, but the absolute error must not exceed $ 10^{-6} $. End the output with a newline.

Sample Input and Output

Sample Input #1

3 2
1 3 5
1 2

Sample Output #1

0.2500000000

Sample Input #2

9 10
11 2 33 4 55 6 77 8 99
10 11 14 19 55 1000000000 4 5 7 8

Sample Output #2

0.2666666667

Notes/Hints

Partial Points

This problem has partial points.

  • If you correctly solve all test cases where $ N_A, N_B ≦ 1000 $ and $ A_i, B_i ≦ 10^5 $, you will be awarded 40 points.
  • If you correctly solve all test cases where $ A_i, B_i ≦ 10^5 $, you will be awarded 70 points.

Sample Explanation 1

The only metasyntactic variable that appears in both Ant's and Bug's source codes is the 1st one, and the metasyntactic variables that appear in at least one of Ant's or Bug's source codes are the 1st, 2nd, 3rd, and 5th ones. Therefore, the Jaccard coefficient is $ 1/4 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 1 3 5 1 2
样例输出
0.2500000000