Easy Math Problem
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+3, 28=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 S be the set of all the true factors of the natural number X. If there is a subset of S 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 24 is {1,2,3,4,6,8,12}, we can select a subset {2,4,6,12}, meet that 24=2+4+6+12. So 24 can be called a semi-perfect number.
Kanari wants to know if he can find an integer k which is a multiple of positive integer p, such that k is a semi-perfect number.
Since Kanari is not good at math, he wants the k not to be too large (k≤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 T (1≤T≤4000) indicating the number of test cases.
Then T cases follow, each of which contains a single interger p (1≤p≤109).
Output
Output 2T lines.
For each test case, if there is some integer k that satisfy the condition, output two space-separated integers on the first line, k (k≤2×1018) and n (1≤n≤1000) (the size of the subset you select). Then output n space-separated integers on the second line, the subset you select.
If you cannot find such k, 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.
Sample Input
2
6
1
Sample Output
48 5
2 4 6 12 24
12 4
1 2 3 6
题意: 求所给数的倍数是半完全数的数,并输出因数和因数的个数
思路: 第一个完全数是6,第二个完全数是28,第三个完全数是496,
AC代码:
#include<stdio.h>
#include<string.h>
#define ll long long
#include<algorithm>
using namespace std;
int main()
{
ll n,m,t;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
printf("%lld 3\n",n*6);
printf("%lld %lld %lld\n",n,2*n,3*n);
}
return 0;
}