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 10<sup class="upper-index">18</sup>.
The first line of the input contains integer *n* (1 ≤ *n* ≤ 1000).
import math

def generate_primes(n):
    """
    Generates all primes up to n.
    """
    primes = []
    is_prime = [True] * (n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i*i, n+1, i):
                is_prime[j] = False
    return primes


def find_smallest_num_with_n_divisors(n):
    """
    Finds the smallest positive integer with exactly n divisors.
    """
    primes = generate_primes(int(math.sqrt(2**31-1)))
    max_prime_count = math.ceil(math.log(2**31-1, 2))
    for i in range(1, max_prime_count+1):
        for primes_combination in itertools.combinations(primes, i):
            num = 1
            for prime in primes_combination:
                if num * prime > 2**31-1:
                    break
                num *= prime
            if num_divisors(num) == n:
                return num


def num_divisors(num):
    """
    Returns the number of divisors of a given number.
    """
    count = 0
    for i in range(1, int(num**0.5)+1):
        if num % i == 0:
            if num // i == i:
                count += 1
            else:
                count += 2
    return count


if __name__ == '__main__':
    n = int(input("Enter the number of divisors: "))
    result = find_smallest_num_with_n_divisors(n)
    print(result)
