CF 27E Number With The Given Amount Of Divisors

A - Number With The Given Amount Of Divisors

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the
answer will not exceed 1018.

Input

The first line of the input contains integer n (1?≤?n?≤?1000).

Output

Output the smallest positive integer with exactly n divisors.

Sample Input

Input

4

Output

6

Input

6

Output

12


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>

using namespace std;

#define ll long long
const int MAXN=10010;;

ll ans;
int n;

int prm[10]={2,3,5,7,11,13,17,19,23,29};

void dfs(int a,int b,ll tmp)
{
    if(tmp<ans && a == n)ans=tmp;
    if(a>=n )return;
    for(int i=1;i<=64;i++)
    {
        if(tmp>ans/prm[b])break;//改为tmp*prm[b]>ans---------wa.........因为longlong * int 可能超出longlong的界限
        tmp*=prm[b];
        dfs(a*(i+1),b+1,tmp);
    }
}

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        ans=LONG_LONG_MAX;
        dfs(1,0,1);
        printf("%lld\n",ans);
    }

    return 0;
}

//prm范围为啥10都够了?我不明白

CF 27E Number With The Given Amount Of Divisors

时间: 2024-10-08 08:54:52

CF 27E Number With The Given Amount Of Divisors的相关文章

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> #incl

【数学】【CF27E】 Number With The Given Amount Of Divisors

传送门 Description 给定一个正整数\(n\),输出最小的整数,满足这个整数有n个因子 Input 一行一个整数\(n\) Output 一行一个整数,代表答案. Hint \(1~\leq~n~\leq~1000\).保证答案不超过\(10^{18}\) Solution 经典题. 引理: 对于一个唯一分解式形如\(x=p_1^{c_1}p_2^{c_2}p_3^{c^3}\cdots p_k^{c_k}\)的数字\(x\),则其因数个数为\(\prod(c_i+1)\). 证明:

CF 466C Number of Ways(数学 / 思维 / DP)

题目链接:http://codeforces.com/problemset/problem/466/C 题目: You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each

CF#235E. Number Challenge

传送门 可以理解为上一道题的扩展板.. 然后我们就可以YY出这样一个式子 ${\sum_{i=1}^a\sum_{j=1}^b\sum_{k=1}^cd(ijk)=\sum_{i=1}^a\sum_{j=1}^b\sum_{k=1}^c[gcd(i,j)=gcd(i,k)=gcd(j,k)=1]\lfloor\frac{a}{i}\rfloor\lfloor\frac{b}{j}\rfloor\lfloor\frac{c}{k}\rfloor}$ 然后我们枚举第一维,排除掉不和第一维互质的数大力

XTU 1242 Yada Number 容斥

Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,13 in its prime factors is even. For instance, 18=2 * 3 * 3 is no

XTU1242:Yada Number

Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,13 in its prime factors is even. For instance, 18=2 * 3 * 3 is no

Change the indent between a list bullet or number and text

Keywords: Office Word Applies To: Word 2007 You can adjust the indents in a list to change how the list items line up. NOTE: For information about adjusting line spacing, see Adjust the spaces between lines or paragraphs. What do you want to do? Adju

xtu 1242 Yada Number 打表

Yada Number       Time Limit : 2000 MS   Memory Limit : 65536 KB Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,

xtu 1242 Yada Number 容斥原理

Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,13 in its prime factors is even. For instance, 18=2 * 3 * 3 is no