[Solution] Doremy's Perfect Math Class Codeforces Solution
"Everybody! Doremy's Perfect Math Class is about to start! Come and do your best if you want to have as much IQ as me!" In today's math class, Doremy is teaching everyone subtraction. Now she gives you a quiz to prove that you are paying attention in class.
You are given a set containing positive integers. You may perform the following operation some (possibly zero) number of times:
- choose two integers and from the set such that and is not in the set .
- add into the set .
You need to tell Doremy the maximum possible number of integers in if the operations are performed optimally. It can be proven that this number is finite.
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line contains an integer () — the size of the set .
The second line contains integers () — the positive integers in .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, you need to output the maximum possible number of integers in . It can be proven that this value is finite.
In the first test case, no such and exist. The maximum possible number of integers in is .
In the second test case,
- at first. You can choose , , then add to the set.
- now. You can choose , , then add to the set.
- now. You can not perform any operation now.
After performing all operations, the number of integers in is . It can be proven that no other sequence of operations allows to contain more than integers.
No comments:
Post a Comment