1703. Non-divisible 2-3 Power Sums

单点时限: 2.0 sec

内存限制: 256 MB

Every positive integer $N$ can be written in at least one way as a sum of terms of the form $(2^a)(3^b)$ where no term in the sum exactly divides any other term in the sum. For example:

  • $1 = (2^0)(3^0)$,
  • $7 = (2^2)(3^0) + (2^0)(3^1)$,
  • $31 = (2^4)(3^0) + (2^0)(3^2) + (2^1)(3^1) = (2^2) + (3^3)$

Note from the example of $31$ that the representation is not unique.

Write a program which takes as input a positive integer $N$ and outputs a representation of $N$ as a sum of terms of the form $(2^a)(3^b)$.

输入格式

The first line of input contains a single integer $C$ ($1 \le C \le 1000$) which is the number of datasets that follow.

Each dataset consists of a single line of input containing a single integer $N$ ($1 \le N < 2^{31}$), which is the number to be represented as a sum of terms of the form $(2^a)(3^b)$.

输出格式

For each dataset, the output will be a single line consisting of: The dataset number, a single space, the number of terms in your sum as a decimal integer followed by a single space followed by representations of the terms in the form x y with terms separated by a single space. x is the power of $2$ in the term and y is the power of $3$ in the term.

样例

Input
6
1
7
31
7776
531441
123456789
Output
1 1 0 0
2 2 0 1 2 0
3 2 0 3 2 0
4 1 5 5
5 1 0 12
6 8 0 16 2 15 3 13 4 12 7 8 9 6 10 5 15 2

4 人解决,13 人已尝试。

4 份提交通过,共有 50 份提交。

8.8 EMB 奖励。

创建: 16 年,7 月前.

修改: 6 年,3 月前.

最后提交: 9 月,2 周前.

来源: Greater New York 2006

题目标签