51nod 1060
反素数
定义:对于任意正整数 $n$, 其约数个数记为 $f(n)$, 如果某个正整数 $n$ 满足
对于任意正整数 $i, (0 < i < n)$, 都有 $f(i) < f(n)$,称 $n$ 为反素数。
so
一个反素数的所有因子必然是从 $2$ 开始的连续质数
如果 $n = 2 ^ {t_1} * 3 ^ {t_2} * 5 ^ {t_3} * \dots$, 那么必有 $t_1 \ge t_2 \ge t_3 \ge \dots$
结合质因数个数的统计方法即可解决此题
#include <bits/stdc++.h> #define gc getchar() #define LL long long inline LL read() { LL x = 0; char c = gc; while(c < '0' || c > '9') c = gc; while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = gc; return x; } const int To = 16; int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}; LL Num, js, n; void Dfs(LL Now_num, LL Now_js, int dep, int pre) { if(dep >= To) return ; if(Now_js > js) { Num = Now_num, js = Now_js; } else if(Now_js == js) { Num = std:: min(Num, Now_num); } for(int i = 1; i <= pre; i ++) { if(Now_num <= n / prime[dep]) { Now_num *= prime[dep]; Dfs(Now_num, Now_js * (i + 1), dep + 1, i); } else break; } } int main() { int T = read(); for(; T; T --) { n = read(); Num = 1, js = 1; Dfs(1, 1, 0, 15); printf("%I64d %I64d\n", Num, js); } return 0; }