The meaning of the question is to give a number, and then find the largest subset of all the factors of this number, except for 1 and itself, so that the elements in this subset are mutually exclusive, evaluate the element count of the largest subset
Number, and the sum of them is the maximum value.
It is not difficult to find a rule. In fact, the answer is to break down n by a large number. For example, 180 = 2 ^ 2*3 ^ 2*5, then 3 18 is output, these two numbers are respectively the number of prime factors and the sum of 2 ^ 2, 3 ^ 2, 5.
[Cpp]
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
# Include <algorithm>
# Include <iostream>
Const int Times = 10;
Const int n= 550;
Using namespace std;
Typedef unsigned _ int64 LL;
LL ct, cnt;
LL fac [N], num [N];
LL gcd (LL a, LL B)
{
Return B? Gcd (B, a % B):;
}
LL multi (LL a, LL B, LL m)
{
LL ans = 0;
While (B)
{
If (B & 1)
{
Ans = (ans + a) % m;
B --;
}
B> = 1;
A = (a + a) % m;
}
Return ans;
}
LL quick_mod (LL a, LL B, LL m)
{
LL ans = 1;
A % = m;
While (B)
{
If (B & 1)
{
Ans = multi (ans, a, m );
B --;
}
B> = 1;
A = multi (a, a, m );
}
Return ans;
}
Bool Miller_Rabin (LL n)
{
If (n = 2) return true;
If (n <2 |! (N & 1) return false;
LL a, m = n-1, x, y;
Int k = 0;
While (m & 1) = 0)
{
K ++;
M> = 1;
}
For (int I = 0; I <Times; I ++)
{
A = rand () % (n-1) + 1;
X = quick_mod (a, m, n );
For (int j = 0; j <k; j ++)
{
Y = multi (x, x, n );
If (y = 1 & x! = 1 & x! = N-1) return false;
X = y;
}
If (y! = 1) return false;
}
Return true;
}
LL pollard_rov (LL n, LL c)
{
LL x, y, d, I = 1, k = 2;
Y = x = rand () % (n-1) + 1;
While (true)
{
I ++;
X = (multi (x, x, n) + c) % n;
D = gcd (y-x + n) % n, n );
If (1 <d & d <n) return d;
If (y = x) return n;
If (I = k)
{
Y = x;
K <= 1;
}
}
}
Void find (LL n, int c)
{
If (n = 1) return;
If (Miller_Rabin (n ))
{
Fac [ct ++] = n;
Return;
}
LL p = n;
LL k = c;
While (p> = n) p = pollard_rov (p, c --);
Find (p, k );
Find (n/p, k );
}
Int main ()
{
Int t;
LL n, ans;
Scanf ("% d", & t );
While (t --)
{
Scanf ("% I64u", & n );
Ct = 0;
Find (n, 120 );
Sort (fac, fac + ct );
Num [0] = 1;
Int k = 1;
For (int I = 1; I <ct; I ++)
{
If (fac [I] = fac [I-1])
+ + Num [k-1];
Else
{
Num [k] = 1;
Fac [k ++] = fac [I];
}
}
Cnt = k;
LL ret = 0;
For (int I = 0; I <cnt; I ++)
{
LL temp = 1;
For (int j = 0; j <num [I]; j ++)
Temp * = fac [I];
Ret + = temp;
}
If (cnt = 1) ret/= fac [0];
Printf ("% I64u % I64u \ n", cnt, ret );
}
Return 0;
}
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
# Include <algorithm>
# Include <iostream>
Const int Times = 10;
Const int n= 550;
Using namespace std;
Typedef unsigned _ int64 LL;
LL ct, cnt;
LL fac [N], num [N];
LL gcd (LL a, LL B)
{
Return B? Gcd (B, a % B):;
}
LL multi (LL a, LL B, LL m)
{
LL ans = 0;
While (B)
{
If (B & 1)
{
Ans = (ans + a) % m;
B --;
}
B> = 1;
A = (a + a) % m;
}
Return ans;
}
LL quick_mod (LL a, LL B, LL m)
{
LL ans = 1;
A % = m;
While (B)
{
If (B & 1)
{
Ans = multi (ans, a, m );
B --;
}
B> = 1;
A = multi (a, a, m );
}
Return ans;
}
Bool Miller_Rabin (LL n)
{
If (n = 2) return true;
If (n <2 |! (N & 1) return false;
LL a, m = n-1, x, y;
Int k = 0;
While (m & 1) = 0)
{
K ++;
M> = 1;
}
For (int I = 0; I <Times; I ++)
{
A = rand () % (n-1) + 1;
X = quick_mod (a, m, n );
For (int j = 0; j <k; j ++)
{
Y = multi (x, x, n );
If (y = 1 & x! = 1 & x! = N-1) return false;
X = y;
}
If (y! = 1) return false;
}
Return true;
}
LL pollard_rov (LL n, LL c)
{
LL x, y, d, I = 1, k = 2;
Y = x = rand () % (n-1) + 1;
While (true)
{
I ++;
X = (multi (x, x, n) + c) % n;
D = gcd (y-x + n) % n, n );
If (1 <d & d <n) return d;
If (y = x) return n;
If (I = k)
{
Y = x;
K <= 1;
}
}
}
Void find (LL n, int c)
{
If (n = 1) return;
If (Miller_Rabin (n ))
{
Fac [ct ++] = n;
Return;
}
LL p = n;
LL k = c;
While (p> = n) p = pollard_rov (p, c --);
Find (p, k );
Find (n/p, k );
}
Int main ()
{
Int t;
LL n, ans;
Scanf ("% d", & t );
While (t --)
{
Scanf ("% I64u", & n );
Ct = 0;
Find (n, 120 );
Sort (fac, fac + ct );
Num [0] = 1;
Int k = 1;
For (int I = 1; I <ct; I ++)
{
If (fac [I] = fac [I-1])
+ + Num [k-1];
Else
{
Num [k] = 1;
Fac [k ++] = fac [I];
}
}
Cnt = k;
LL ret = 0;
For (int I = 0; I <cnt; I ++)
{
LL temp = 1;
For (int j = 0; j <num [I]; j ++)
Temp * = fac [I];
Ret + = temp;
}
If (cnt = 1) ret/= fac [0];
Printf ("% I64u % I64u \ n", cnt, ret );
}
Return 0;
}