Topic link address: http://codeforces.com/problemset/problem/27/E
Question: Given a number , find the smallest positive integer such that the number of factors is .
Analysis: Similar to the method for finding factors, first build a search tree, build a tree structure with each one as a layer, perform a search, and take the smallest one.
Taking an example to illustrate, the construction is as follows:
It can be seen that all numbers on the path from the root node to each leaf node are multiplied by the divisor of 12, so 12 has 6 divisors.
The idea of searching is obvious. From the root node to perform a deep search, to the leaf node, the code is as follows:
void dfs(int dept,LL ans = 1) { if(dept == cnt) { make[ct ++] = ans; return ; } for(int i=0;i<=num[dept];i++) { dfs(dept + 1 , years); years *= pri[dept]; } }