AtCoder Regular Contest 158
A
+3 +5 +7
AtCoder
⌀ 720
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given integers $x_1$, $x_2$, and $x_3$. For these integers, you can perform the following operation any number of times, possibly zero.

翻译中…
  • Choose a permutation $(i,j,k)$ of $(1,2,3)$, that is, a triple of integers $(i,j,k)$ such that $1\leq i,j,k\leq 3$ and $i\neq j, i\neq k, j\neq k$.
  • Then, simultaneously replace $x_i$ with $x_i+3$, $x_j$ with $x_j+5$, and $x_k$ with $x_k+7$.
翻译中…

Your objective is to satisfy $x_1=x_2=x_3$. Determine whether it is achievable. If it is, print the minimum number of times you need to perform the operation to achieve it.

翻译中…

You have $T$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1\leq T\leq 2\times 10^5$
  • $1\leq x_1, x_2, x_3 \leq 10^9$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
\text{case}_1
\vdots
\text{case}_T

翻译中…

Each test case is in the following format:

翻译中…

x_1 x_2 x_3

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the following value for the $i$-th test case.

翻译中…
  • The minimum number of times you need to perform the operation to satisfy $x_1=x_2=x_3$, if it is possible to satisfy this.
  • $-1$, otherwise.
翻译中…

样例

Input #1
4
2 8 8
1 1 1
5 5 10
10 100 1000
Output #1
2
0
-1
315
For the first test case, you can do the following to satisfy $x_1=x_2=x_3$. - Perform the operation with $(i,j,k) = (3,2,1)$, replacing $(x_1,x_2,x_3)$ with $(9,13,11)$. - Perform the operation with $(i,j,k) = (2,3,1)$, replacing $(x_1,x_2,x_3)$ with $(16,16,16)$.
题目信息
题号
arc158_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。