#P7649. [BalticOI 2004] Scales (Day1)
[BalticOI 2004] Scales (Day1)
Description
You are given a balanced beam scale, a set of weights, and an object. The weights are , that is, each weight is a power of , and for every integer there is exactly one weight of mass . The object has mass , where is a positive integer. Your task is to place the object on the left pan, and then place some of the weights on the left pan, the right pan, or both, so that the scale is balanced.
Input Format
The first line contains an integer .
Output Format
The first line contains information about the weights placed on the left pan. The first number must be a non-negative integer, the number of weights placed on the left pan, followed by the weights’ masses in increasing order. The numbers must be separated by a single space. The second line contains information about the weights placed on the right pan in the same format as the first line.
42
3 3 9 27
1 81
30
0
2 3 27
Hint
Constraints
For of the testdata, .
Notes
From Day 1:SCALES of Baltic Olympiad in Informatics 2004.
Translated and organized by @求学的企鹅.
Translated by ChatGPT 5
京公网安备 11011102002149号