传送门

看完题发现很sb。

前10个质数乘起来已经超出题目范围了。

因此只用搜索前几个质数每个的次数比较谁的因数的就行了。

代码:

#include<iostream>
#define ll long long
using namespace std;
int pri[10]={2,3,5,7,11,13,17,19,23,29};
ll n,maxcnt,ans;
inline void dfs(int pos,ll cnt,ll mul){
    if(cnt>maxcnt)maxcnt=cnt,ans=mul;
    else if(cnt==maxcnt&&ans>mul)ans=mul;
    if(pos==9)return;
    for(int i=0;mul<=n;mul*=pri[pos],++i)dfs(pos+1,cnt*(i+1),mul);
}
int main(){
    cin>>n;
    dfs(0,1,1);
    cout<<ans;
    return 0;
}
05-11 10:49
查看更多