#P9652. 『GROI-R2』 紫水晶
『GROI-R2』 紫水晶
Problem Description
Alice has never forgotten that she once existed in the world of playing cards.
So magic made some cards appear in her hand. Magic also made some cards appear in Taniel’s hand, and on each card there was a positive integer—even though they are now in the Glass Kingdom.
The cards quickly vanished, and they were ready to set off. Alice only remembered the sum of the greatest common divisors of each pair of adjacent cards, and Taniel only remembered the sum of the least common multiples of each pair of adjacent cards.
You are still in this palace, and you want to recreate the cards from that time.
Formal statement
You are given queries. Each query is one of the following two types:
-
1 n xmeans you need to output a positive integer sequence of length , such that . -
2 n xmeans you need to output a positive integer sequence of length , such that $\sum\limits_{i=1}^{n-1} \operatorname{lcm}(a_i,a_{i+1})=x$.
Also, for any output, each must not exceed the storage range of int in C++.
Here, and are the greatest common divisor and least common multiple. If there are multiple solutions, you may output any one. If there is no solution, output -1.
Input Format
The first line contains a positive integer , the number of queries.
Then follow lines. Each line contains three positive integers .
-
When , it means Alice has cards and the sum she remembered is . You need to restore her cards.
-
When , it means Taniel has cards and the sum he remembered is . You need to restore his cards.
Output Format
Output lines. On each line, output an integer sequence for the card sequence you construct for that query. Adjacent numbers in the sequence should be separated by a single space.
If there are multiple solutions, you may output any one. If there is no solution, output -1.
5
1 5 4
2 3 8
1 5 10
2 6 34
1 3 1
1 1 1 1 1
2 2 3
1 1 1 7 7
1 1 4 5 1 4
-1
Hint
Constraints
This problem uses bundled testdata.
| Special property | Score | |||
|---|---|---|---|---|
Special property : it is guaranteed that for every query, .
Special property : it is guaranteed that for every query, .
For of the data, , , , and .
Translated by ChatGPT 5