@Link
Solution
Suppose
a
=
p
1
a
1
∗
p
2
a
2
∗
.
.
.
a = p_1^{a_1} * p_2^{a_2} * ...
a=p1a1∗p2a2∗... where
p
1
≤
p
2
≤
.
.
.
p_1 \leq p_2 \leq ...
p1≤p2≤... is an Anti-Prime, it would has some properties:
.
a
1
≥
a
2
≥
.
.
.
a_1 \geq a_2 \geq ...
a1≥a2≥...; (if not, e.g.,
a
=
2
1
∗
3
2
a=2^1 * 3^2
a=21∗32, another number
b
=
2
2
∗
3
1
b = 2^2 * 3^1
b=22∗31 which own the same Divisor-Count with
a
a
a, while
b
<
a
b < a
b<a implies
a
a
a is not Anti-Prime)
.
p
1
=
2
,
p
2
=
3
,
p
3
=
5
,
.
.
.
p_1 = 2, p_2 = 3, p_3 = 5, ...
p1=2,p2=3,p3=5,...; (the analysis is similar to the above)
Due to these two properties, actually we can use DFS-Brute to finding all such numbers
a
a
a (notice,
a
a
a may not be a Anti-Prime; e.g., in the range of int
, the number of such
a
a
a is greater than the number of Anti-Prime), the number of such
a
a
a would not too much even in the whole range of int
, cuz
2
∗
3
∗
5
∗
7
∗
.
.
.
2*3*5*7*...
2∗3∗5∗7∗... at most
9
9
9 Primes-Factor would attain the maximum of int
;
Code
int P[] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
long long N;
long long Cont, Ans;
void Dfs( int _ind, int _power, int _cont, long long _n){
if( _ind >= 9){ return;}
long long cur = 1;
for( int p = 1; p <= _power; ++p){
cur *= P[ _ind];
if( _n * cur > N){ break;}
if( (_cont * (p + 1) > Cont) || ((_cont * (p + 1) == Cont) && (_n * cur < Ans))){
Cont = _cont * (p + 1);
Ans = _n * cur;
}
Dfs( _ind + 1, p, _cont * (p + 1), _n * cur);
}
}
scanf("%lld", &N);
Cont = 1, Ans = 1;
Dfs( 0, 100, 1, 1);
cout<< Ans;