27E - Number With The Given Amount Of Divisors
2014-08-05 16:17
387 查看
假设P(i)代表某个素数,a(i)代表这个素数的幂
那么任何一个数都可以分解成 ( P(1)^a(1) )*( P(2)^a(2) )*( P(3)^a(3) )*.............*( P(k)^a(k) )
而且这个数的约数的数量为 (a(1)+1)*(a(2)+1)*(a(3)+1)*.............*(a(k)+1) (包括该数本身
那么任何一个数都可以分解成 ( P(1)^a(1) )*( P(2)^a(2) )*( P(3)^a(3) )*.............*( P(k)^a(k) )
而且这个数的约数的数量为 (a(1)+1)*(a(2)+1)*(a(3)+1)*.............*(a(k)+1) (包括该数本身
</pre><pre name="code" class="html">#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<map> #include<set> #include<vector> #include<stack> #include<queue> #include<algorithm> #include<cmath> #define ll long long #define ULL unsigned long long using namespace std; const int INF=0x3f3f3f3f; const long long LINF=ceil(1e18); int p[11]={1,2,3,5,7,11,13,17,19,23,29}; ll ans; void dfs(int x,int n,long long M) { if(n==1) { ans=min(ans,M); return; } long long k=p[x]; for(int l=1;l<n&&k<LINF;l++,k=k*p[x]) if(n%(l+1)==0) { if(M*k>LINF||M*k<=0) break; dfs(x+1,n/(l+1),M*k); } } int main() { //freopen("data.in","r",stdin); int n; while(~scanf("%d",&n)) { ans=LINF; dfs(1,n,1); printf("%lld\n",ans); } return 0; }
相关文章推荐
- CodeForces - 27E--Number With The Given Amount Of Divisors(反素数)
- Codeforces Beta Round #27 (Codeforces format, Div. 2) E. Number With The Given Amount Of Divisors 反素数
- Ccodeforces 27E Number With The Given Amount Of Divisors(数论+搜索)
- Codeforces 27 E Number With The Given Amount Of Divisors
- day4 CodeForces 27E Number With The Given Amount Of Divisors
- CodeForces - 27E Number With The Given Amount Of Divisors (DFS+数学)
- CodeForces 27 E.Number With The Given Amount Of Divisors(dfs)
- CF-27E - Number With The Given Amount Of Divisors(枚举+dfs)
- Codeforces 27E Number With The Given Amount Of Divisors (求约数个数为n的最小数)
- Codeforces 27E. Number With The Given Amount Of Divisors (暴力)
- codeforces 27E Number With The Given Amount Of Divisors(反素数)
- codeforces 27E Number With The Given Amount Of Divisors
- Codeforces 27E Number With The Given Amount Of Divisors
- CodeForce 27E: Number With The Given Amount Of Divisors(求反素数)
- CF-27E - Number With The Given Amount Of Divisors(枚举+dfs)
- CodeForces 27E Number With The Given Amount Of Divisors
- Codeforces 27E - Number With The Given Amount Of Divisors
- CF 27E Number With The Given Amount Of Divisors
- codeforces 27 E. Number With The Given Amount Of Divisors(反素数)
- codeforces 27E - Number With The Given Amount Of Divisors (数论 dfs)