思 维 题

1.题目输出:

Kanari recently worked on perfect numbers. 

Perfect numbers are a special kind of natural numbers. A number is a perfect number if and only if the sum of all the true factors (divisors other than itself) is equal to itself. Such as 6=1+2+36=1+2+3, 28=1+2+4+7+1428=1+2+4+7+14, etc. 

Kanari made a kind of semi-perfect number of his own according to the definition of perfect number. 

Let SS be the set of all the true factors of the natural number XX. If there is a subset of SS such that the sum of the numbers in the subset is equal to the number itself, the number is said to be semi-perfect. 

Obviously, all perfect numbers are semiperfect numbers. In addition, there are some numbers that are not perfect, and they also belong to Kanari's semi-perfect numbers. For example, the true factors set of 2424 is {1,2,3,4,6,8,12}{1,2,3,4,6,8,12}, we can select a subset {2,4,6,12}{2,4,6,12}, meet that 24=2+4+6+1224=2+4+6+12. So 2424can be called a semi-perfect number. 

Kanari wants to know if he can find an integer kk which is a multiple of positive integer pp, such that kk is a semi-perfect number. 

Since Kanari is not good at math, he wants the kk not to be too large (k≤2×1018k≤2×1018), and the size of the subset is not larger than 1000. He wants you to give the subset you select.

Input

This problem contains multiple test cases. 

The first line contains a single integer TT (1≤T≤40001≤T≤4000) indicating the number of test cases. 

Then TT cases follow, each of which contains a single interger pp (1≤p≤1091≤p≤109).

Output

Output 2T2T lines. 

For each test case, if there is some integer kk that satisfy the condition, output two space-separated integers on the first line, kk (k≤2×1018k≤2×1018) and nn (1≤n≤10001≤n≤1000) (the size of the subset you select). Then output nn space-separated integers on the second line, the subset you select. 

If you cannot find such kk, output "-1" on the first line, and an empty line on the second line. 

Please don't output extra space at the end of each line.

2.样例输出: 

Sample Input

2
6
1

Sample Output

48 5
2 4 6 12 24
12 4
1 2 3 6

题目大意:寻找最小半完全数(即它的因数子集找到一些数的相加和等于这个数),当然这个数必须是所给数的倍数。我们可以反其道而行,可以发现 6 就是最小的符合条件的数,所以这个数只要是 6 的倍数即可 而它对应的子集 分别是: 1,2,3 的倍数。 

3.代码如下: 

#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	while(n--)
	{
		ll q;
		cin>>q;
		cout<<q*6<<" 3\n";
		cout<<q<<" "<<q*2<<" "<<q*3<<"\n";
	} 
	return 0;	
} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风遥~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值