#P7383. 「EZEC-6」加减
「EZEC-6」加减
Description
You are given two numbers . You need to split into distinct positive integers (that is, the sum of these numbers is ), such that within the interval , there is at least one positive integer that cannot be obtained by adding and subtracting these numbers (each number can be used at most once in the adding/subtracting process).
That is, let the -th number among the positive integers be . You need to ensure that within , there exists at least one positive integer that cannot be represented in the form $\sum\limits^{n}_{i=1} k_i \times a_i \ (k_i \in \{-1, 0, 1\})$.
If there is no solution, output -1.
If there is a solution, output any set of positive integers that meets the requirement, and also output any number in that cannot be represented.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , the number of test cases.
For each test case, one line contains two positive integers .
Output Format
For each test case:
If there is no solution, output one line -1.
If there is a solution, output positive integers in the first line, representing a valid solution, and output one positive integer in in the second line. This integer cannot be represented.
4
2 6
3 18
1 1
2 4
1 5
3
5 6 7
3
-1
-1
Hint
This problem uses bundled tests.
- Subtask 1 (10 points): .
- Subtask 2 (20 points): .
- Subtask 3 (20 points): .
- Subtask 4 (20 points): .
- Subtask 5 (30 points): no special constraints.
Constraints: For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号