描述
Consider the set of all non-negative integer powers of 3.
S = { 1, 3, 9, 27, 81, ... }
Consider the sequence of all subsets of S ordered by the value of the sum of their elements. The question is simple: find the set at the n-th position in the sequence and print it in increasing order of its elements.
输入
Each line of input contains a number n, which is a positive integer with no more than 19 digits. The last line of input contains 0 and it should not be processed.
输出
For each line of input, output a single line displaying the n-th set as described above, in the format used in the sample output.
翻译
描述
考虑所有3的非负整数幂的集合。
S = { 1, 3, 9, 27, 81, ... }
考虑S的所有子集按其元素和的值排序的序列。问题很简单:找到序列中第n个位置的集合,然后按元素的递增顺序输出。
输入
每一行输入一个数字n, n是一个不超过19位的正整数。输入的最后一行包含0,表述输入结束。
输出
对于每一行输入,按示例输出中使用的格式输出一行,显示上面所述的第n个集合。