#P6068. 『MdOI R1』GCD? GCD!
『MdOI R1』GCD? GCD!
Problem Description
Ling likes , that is, the greatest common divisor. If you do not know what the greatest common divisor is, you can visit Greatest Common Divisor - OI Wiki.
Ling gives you a positive integer and asks you to split it into the sum of three pairwise distinct positive integers , such that is as large as possible.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , which indicates the number of test cases.
The next lines each contain a positive integer .
Output Format
For each test case, output one integer per line, which is the answer, i.e., the maximum possible value of .
In particular, if cannot be written as the sum of three pairwise distinct positive integers, output -1.
3
12
27
5
2
3
-1
Hint
[Sample Explanation]
Split into . It can be proven that is the maximum possible value.
Split into . It can be proven that is the maximum possible value.
cannot be written as the sum of three pairwise distinct positive integers, so output -1.
[Constraints]
This problem uses bundled testdata.
| Subtask ID | Score | |
|---|---|---|
| 1 | 17 | |
| 2 | 19 | |
| 3 | 23 | |
| 4 | 41 |
For of the testdata, and .
Translated by ChatGPT 5