+3 +5 +7

AtCoder
IDarc158_a
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
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)$.
API Response (JSON)
{
  "problem": {
    "name": "+3 +5 +7",
    "description": {
      "content": "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 i",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc158_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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.\n\n*   Choose a permutation $(i,j,k)$ of $(1,2,3)$, that i...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments