Algorithm


E. Number With The Given Amount Of Divisors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
input
Copy
4
output
Copy
6
input
Copy
6
output
Copy
12



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>
#include <vector>
typedef long long ll;

int main(){

    long rv[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 47, 53};
    long n; scanf("%ld", &n);

    if(n == 8){puts("24"); return 0;} // Special case;

    std::vector<long> pdiv;
    long cur(2);
    while(cur <= n){
        while(n % cur == 0){pdiv.push_back(cur); n /= cur;}
        ++cur;
    }
    if(n > 1){pdiv.push_back(n);}

    ll res(1), ind(0);
    for(long p = 0; p < pdiv.size(); p++){
        long ind = pdiv.size() - p - 1;
        long u = pdiv[ind] - 1; while(u--){res *= rv[p];}
    }

    printf("%lld\n", res);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4

Output

x
+
cmd
6
Advertisements

Demonstration


Codeforces Solution-E. Number With The Given Amount Of Divisors-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+