编程介的小学生 2017-03-24 05:13 采纳率: 20.5%
浏览 698
已采纳

Non-divisible 2-3 Power Sums

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

1 = (20)(30)
7 = (22)(30) + (20)(31)
31 = (24)(30) + (20)(32) + (21)(31) = (22) + (33)
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 (2a)(3b).

Input

The first line of input contains a single integer C, (1 <= C <= 1000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing a single integer N, (1 <= N < 231), which is the number to be represented as a sum of terms of the form (2a)(3b).

Output

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 [,] with terms separated by a single space. is the power of 2 in the term and is the power of 3 in the term.

Sample Input

6
1
7
31
7776
531441
123456789
Sample Output

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]

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-04-01 15:16
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数