http://blog.youkuaiyun.com/miaomiao_ymxl/article/details/52443371
My Mom传送门~~~~~十分十分的详细!!!
我就不做解释了,直接给代码好了(好迷啊(迷惑脸....))
[[[这里给出日常错误点吧~
Hans做此题wa了无数次,最后终于发现了错误!!!我!没写!lld!写的是!d!QuQ心好痛........
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long n, ans, cnt;
const int ss[16] = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
void dfs(long long now_num, long long k_ss, long long now_cnt, int maxxcnt){
if(k_ss >= 16) return;
if(now_cnt > cnt || (now_cnt == cnt && now_num < ans)){
cnt = now_cnt;
ans = now_num;
}
long long temp = ss[k_ss];
for(long long i = 1; i <= maxxcnt; i++){
if(temp > n / now_num)
break;
dfs(now_num*temp, k_ss+1, now_cnt*(i+1), i) ;
temp *= ss[k_ss];
}
}
int main(){
int t;
scanf("%d", &t);
while(t--){
scanf("%lld", &n);
ans = cnt = 1LL;
dfs(1, 1, 1, 50);
printf("%lld %lld\n", ans, cnt);
}
return 0;
}