Construct a Coin Set
시간 제한1초메모리 제한1024 MB
각 N에 대해 1원부터 N-1원까지는 그리디가 최적해를 주지만 N원에서는 그렇지 않은 동전 집합을 만들거나, 불가능하면 -1을 출력한다.
문제
The change-making problem is the problem of finding the minimum number of coins that add up to the change to be returned after purchasing items at a shop. A coin set refers to a collection of coin values available for making the change. The greedy algorithm for the change-making problem repeatedly selects the largest coin value among the coin set that does not exceed the remaining amount of change. This process continues until the total amount of change is made.
An optimal solution refers to a solution that uses the fewest number of coins. However, the greedy algorithm does not always guarantee an optimal solution. Under certain conditions, the greedy algorithm may give a non-optimal solution.
Given a positive integer , your task is to find a coin set for which the greedy algorithm returns an optimal solution for all amounts from won to won, but not for won. Notice that the coin whose value is is always in the coin set.
입력
The first line of input contains the number of test cases . Each of the next lines of input contains a single integer .
출력
For each test case,
If it is impossible to construct a coin set satisfying the conditions given in the problem, print .
If it is possible to construct a coin set, print the size of the coin set in the first line. In the next line, print the coin values , separated by spaces in increasing order. The size of the coin set does not have to be a minimum.