codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论
Posted yohaha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论相关的知识,希望对你有一定的参考价值。
首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数。
然后就可以搜了
#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 namespace std; #define pb(x) push_back(x) #define ll long long #define mk(x, y) make_pair(x, y) #define lson l, m, rt<<1 #define mem(a) memset(a, 0, sizeof(a)) #define rson m+1, r, rt<<1|1 #define mem1(a) memset(a, -1, sizeof(a)) #define mem2(a) memset(a, 0x3f, sizeof(a)) #define rep(i, n, a) for(int i = a; i<n; i++) #define fi first #define se second typedef pair<int, int> pll; const double PI = acos(-1.0); const double eps = 1e-8; const int mod = 1e9+7; const int inf = 1061109567; const int dir[][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; int n, f[105], prime[20], cnt; ll ans = 1e18+2; void dfs(int pos, int num, ll val) { if(pos>16) return ; if(num>n) return ; if(num == n) { ans = min(ans, val); return ; } for(int i = 1; i<=60; i++) { val *= prime[pos]; if(val>ans) break; dfs(pos+1, num*(i+1), val); } } int main() { cin>>n; for(int i = 2; i<100; i++) { if(!f[i]) { for(int j = i+i; j<100; 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 搜索+数论的主要内容,如果未能解决你的问题,请参考以下文章
数学CF27E Number With The Given Amount Of Divisors
CodeForces 724G: Xor-matic Number of the Graph
Codeforces 55D Beautiful Number