大和証券プログラミングコンテスト2021 (AtCoder Regular Contest 128)
翻译中…
Problem Statement
翻译中…
We have $R$ red balls, $G$ green balls, and $B$ blue balls. You can do the following operation any number of times:
翻译中…
- choose two balls of different colors and turn them into two balls of the remaining color.
翻译中…
For example, you can choose a red ball and a blue ball and turn them into two green balls.
翻译中…
Your objective is to make all balls have the same color. Determine whether this objective is achievable. If it is, find the minimum number of operations required to achieve it.
翻译中…
For each input file, solve $T$ test cases.
翻译中…
Constraints
翻译中…
$1 \leq T \leq 100$$1 \leq R,G,B \leq 10^8$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
T
case_1
case_2
\vdots
case_T
翻译中…
Each case is in the following format:
翻译中…
R G B
翻译中…
Output
翻译中…
For each case, print -1 if the objective is unachievable; otherwise, print the minimum number of operations to achieve it.
翻译中…
样例
Input #1
3
1 2 2
1 2 3
1 2 4
Output #1
2
-1
4
For example, in $case_3$, one optimal sequence of operations is:
- choose a green ball and blue ball, turning them into two red balls;
- choose a red ball and blue ball, turning them into two green balls;
- choose a red ball and blue ball, turning them into two green balls;
- choose a red ball and blue ball, turning them into two green balls.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。