QOJ.ac

QOJ

時間限制: 0.2 s 記憶體限制: 64 MB 總分: 100

#1473. 不可整除的 2-3 幂和

统计

每一个正整数 $N$ 都可以至少以一种方式写成若干项之和,其中每一项的形式为 $(2^a)(3^b)$,且这些项中没有任何一项能整除其他任何一项。例如:

$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)$

请注意,从 $31$ 的例子可以看出,这种表示方法并不唯一。

编写一个程序,输入一个正整数 $N$,并输出 $N$ 的一种表示形式,将其写成若干项之和,其中每一项的形式为 $(2^a)(3^b)$。

输入格式

输入的第一行包含一个整数 $C$ ($1 \le C \le 1000$),表示数据集的数量。

每个数据集包含一行,输入一个整数 $N$ ($1 \le N < 2^{31}$),即需要表示为 $(2^a)(3^b)$ 之和的数字。

输出格式

对于每个数据集,输出一行,包含:数据集编号,一个空格,和中项的数量(十进制整数),紧接着一个空格,然后是各项的表示形式,格式为 [<2 exponent>,<3 exponent>],各项之间用单个空格分隔。其中 <2 exponent> 是该项中 $2$ 的指数,<3 exponent> 是该项中 $3$ 的指数。

样例

输入格式 1

6
1
7
31
7776
531441
123456789

输出格式 1

1 1 [0,0]
2 2 [2,0] [0,1]
3 3 [4,0] [0,2] [1,1]
4 1 [5,5]
5 1 [0,12]
6 8 [3,13] [4,12] [2,15] [7,8] [9,6] [0,16] [10,5] [15,2]

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.