不难发现,要让约数尽可能多,那么素因子越小的的指数一定越大
可能的素因数的种类也不超过10种
然后直接暴搜即可
1 const p:array[1..10] of longint=(2,3,5,7,11,13,17,19,23,29); 2 var n,ant,ans:int64; 3 procedure dfs(j:longint;m,s,t:int64); 4 var i:longint; 5 begin 6 m:=m*int64(p[j]); 7 if m>n then exit; 8 s:=s div t*(t+1); 9 if (s>ans) then 10 begin 11 ant:=m; 12 ans:=s; 13 end 14 else if (s=ans) and (ant>m) then 15 ant:=m; 16 dfs(j,m,s,t+1); 17 for i:=j+1 to 10 do 18 dfs(i,m,s,1); 19 end; 20 21 begin 22 readln(n); 23 ans:=1; 24 ant:=1; 25 if n>1 then dfs(1,1,1,1); 26 writeln(ant); 27 end. 28 29