[Solution] Patchouli's Magical Talisman Codeforces Solution | Codeforces Problem Solution 2022
Patchouli is making a magical talisman. She initially has magical tokens. Their magical power can be represented with positive integers .
Patchouli may perform the following two operations on the tokens.
- Fusion: Patchouli chooses two tokens, removes them, and creates a new token with magical power equal to the sum of the two chosen tokens.
- Reduction: Patchouli chooses a token with an even value of magical power , removes it and creates a new token with magical power equal to .
Tokens are more effective when their magical powers are odd values. Please help Patchouli to find the minimum number of operations she needs to make magical powers of all tokens odd values.
Each test contains multiple test cases.
The first line contains a single integer () — the number of test cases. The description of the test cases follows.
For each test case, the first line contains one integer () — the initial number of tokens.
The second line contains intergers () — the initial magical power of the tokens.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single integer — the minimum number of operations Patchouli needs to make all tokens have an odd value of magical power.
It can be shown that under such restrictions the required sequence of operations exists.
No comments:
Post a Comment