The Jaccard index is a statistic used for comparing the similarity and diversity of two sets. Namely, the Jaccard index of and is
For example, the Jaccard index of the sets and is .
Write a program to compute the Jaccard index of pairs of sets of integers.
The input consists of several cases. Each case starts describes two sets and . The first set starts with its cardinality and then follow its integer elements in strictly increasing order. The second set starts with its cardinality and then follow its integer elements in strictly increasing order. For each case, .
For each case in the input, print the Jaccard index of its two sets in a different line with 3 digits of precision.
Basic set theory may save you some valuable coding time.
Use @cout.setf(ios::fixed); cout.precision(3);@ at the beginning of your program to print real numbers with 3 digits of precision.
Input
3 1 2 3 2 3 4 11 -9 -7 -5 -1 3 4 5 8 11 17 19 11 -8 -5 -4 1 3 6 8 9 11 12 17 0 3 1 2 3
Output
0.250 0.294 0.000