-->
当前位置:首页 > 题库

PROGRAMMING:Set similarity

Luz5年前 (2021-05-10)题库417
Given two sets of integers, their similarity is defined as: $$n_ c / N_ t \times 100\%$$。 Where $$n_ C $$is the number of unequal integers in both sets, $$n_ T $$is the number of unequal integers shared by two sets. Your task is to calculate the similarity of any pair of given sets.
###Input format:
Enter the first line to give a positive integer, $$n $$($$Le 50 $$), which is the number of sets. Next, there are $$n $$rows, each corresponding to a set. Each set first gives a positive integer, $$M $$($$le10 ^ 4 $$), which is the number of elements in the set; Then it is followed by an integer in the range of $$M $$[0, 10 ^ 9] $.
The next line gives a positive integer $$k $$($$Le 2000 $$), followed by $$k $$lines. Each line corresponds to the number of a pair of sets that need to calculate the similarity (set number from 1 to $$n $$). Numbers are separated by spaces.
###Output format:
For each pair of sets that need to be calculated, output their similarity in a row, which is a percentage number of 2 decimal places.
###Input example:
```in
three
3 99 87 101
4 87 101 5 87
7 99 101 18 5 135 18 99
two
1 2
1 3
```
###Output example:
```out
50%
33.33%
```






answer:If there is no answer, please comment