51Nod-1060-最复杂的数
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const ull INF = ~0ull; int Num; ull n,ans; int p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; void dfs(int dep, ull tmp, int num, int pre) { if(dep >= 16) return ; if(tmp > n) return ; if(num > Num) { Num = num; ans = tmp; } else if(num == Num && tmp < ans) ans = tmp; for(int i=1;i<=pre;i++) { if(n/p[dep] < tmp) break; dfs(dep+1, tmp*=p[dep], num*(i+1), i); } } int main() { int T; scanf("%d", &T); while(T--) { scanf("%llu", &n); ans = INF; Num = 0; dfs(0,1,1,20); printf("%llu %d\n", ans, Num); } return 0; }