Topic links
First of all to know a property, a number X Factor number equals A1^P1 * A2^P2*....AN^PN, AI is the X-Factor, p is the number of quality factors.
And then we can search.
#include <iostream>#include<vector>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<map>#include<Set>#include<string>#include<queue>#include<stack>#include<bitset>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (i, N, a) for (int i = A; i<n; i++)#defineFi first#defineSe Secondtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };intN, f[ the], prime[ -], cnt;ll ans= 1e18+2;voidDfsintPosintnum, ll val) { if(pos> -) return ; if(num>N)return ; if(num = =N) {ans=min (ans, Val); return ; } for(inti =1; i<= -; i++) {Val*=Prime[pos]; if(val>ans) Break; DFS (POS+1, num* (i+1), Val); }}intMain () {CIN>>N; for(inti =2; i< -; i++) { if(!F[i]) { for(intj = i+i; j< -; j+=i) {f[j]=1; } prime[cnt++] =i; }} DFS (0,1,1); cout<<ans<<Endl; return 0;}
Codeforces 27E. Number with the Given Amount of divisors search + number theory