• 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;
    }
  • 相关阅读:
    Another mysql daemon already running with the same unix socket
    cloud maintenance of OpenNebula
    内核分析阅读笔记
    eucalyptus,openNebula云构建漫谈
    quotation
    Adress
    cos
    COS回应7大质疑
    linux内核地址mapping
    开源 免费 java CMS
  • 原文地址:https://www.cnblogs.com/yohaha/p/5269209.html
Copyright © 2020-2023  润新知