CodeForces - 27E

Posted war1111

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 27E相关的知识,希望对你有一定的参考价值。

https://vjudge.net/problem/CodeForces-27E

求因子个数为n的最小的数
dfs枚举质因子的幂

技术图片

#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf ~0
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(unsigned long long i=a;i<=b;++i)

using namespace std;
unsigned long long n,ans;
unsigned long long prime[]=2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53;
void in(unsigned long long &x)
    unsigned long long y=1;char c=getchar();x=0;
    while(c<0||c>9)if(c==-)y=-1;c=getchar();
    while(c<=9&&c>=0) x=(x<<1)+(x<<3)+c-0;c=getchar();
    x*=y;

void o(unsigned long long x)
    if(x<0)p(-);x=-x;
    if(x>9)o(x/10);
    p(x%10+0);


void dfs(unsigned long long depth,unsigned long long num,unsigned long long cnt,unsigned long long up)
    if(cnt>n)
        return;
    if(cnt==n&&ans>num)
        ans=num;
        return;
    
    For(i,1,up)
        if(num*prime[depth]>ans) return;
        dfs(depth+1,num*=prime[depth],cnt*(i+1),i);
    


int main()
    in(n);
    ans=inf;
    dfs(0,1,1,64);
    o(ans);
    return 0;

 

以上是关于CodeForces - 27E的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 27

Educational Codeforces Round 27

7-27 Codeforces Round #499 (Div. 2)

codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论

Educational Codeforces Round 27 C

Educational Codeforces Round 27 D. Driving Test