zoukankan      html  css  js  c++  java
  • 51nod 四级题 汇总

    51Nod-1060-最复杂的数

    #include <bits/stdc++.h>
    using namespace std;
    
    typedef unsigned long long ull;
    const ull INF = ~0ull;
    int Num;
    ull n,ans;
    int p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
    
    void dfs(int dep, ull tmp, int num, int pre)
    {
        if(dep >= 16) return ;
        if(tmp > n) return ;
        if(num > Num) {
            Num = num;
            ans = tmp;
        }
        else if(num == Num && tmp < ans)
            ans = tmp;
        for(int i=1;i<=pre;i++) {
            if(n/p[dep] < tmp) break;
            dfs(dep+1, tmp*=p[dep], num*(i+1), i);
        }
    }
    
    int main()
    {
        int T; scanf("%d", &T);
        while(T--) {
            scanf("%llu", &n);
            ans = INF;
            Num = 0;
            dfs(0,1,1,20);
            printf("%llu %d
    ", ans, Num);
        }
        return 0;
    }
    搜索 + 剪枝
  • 相关阅读:
    NFS服务安装
    Redhat 6.3 yum 本地源配置
    在redhat enterprise linux 6中部署samba
    React
    链表
    map, set
    二叉查找树
    数制间的相互转换
    二维数组
    拖拽
  • 原文地址:https://www.cnblogs.com/Draymonder/p/10033243.html
Copyright © 2011-2022 走看看