#K13156. Unique Book Combinations
Unique Book Combinations
Unique Book Combinations
You are given the number of students and information about book exchanges. Each student initially had some books, though this information does not affect the calculation. After the exchange, each student receives one or more books. Your task is to determine the number of unique book types that appear in the exchange.
Formally, given an integer \( n \) representing the number of students, an array of \( n \) integers (which can be ignored for the purpose of this problem), and another array containing the exchanged book types, compute the number of distinct elements in the exchanged book types array.
For example, if the exchanged book types are [2, 3, 6, 7, 8, 9, 10]
, the answer is 7
since there are 7 unique book types.
inputFormat
The input is given via stdin in the following format:
- An integer \(n\) representing the number of students.
- A line containing \(n\) space-separated integers representing the original number of books for each student. (This data is not necessary for the computation.)
- An integer \(m\) representing the number of exchanged books.
- A line containing \(m\) space-separated integers representing the types of books each student received after the exchange.
Note: For cases where \(n = 0\) or \(m = 0\), the corresponding line for the list of integers will be empty.
outputFormat
The output should be a single integer printed to stdout - the number of unique book types present in the exchanged books list.
## sample3
2 3 4
7
2 3 6 7 8 9 10
7