#P8084. Find the N-th Smallest Positive Integer with a Given Smallest Prime Factor
Find the N-th Smallest Positive Integer with a Given Smallest Prime Factor
Find the N-th Smallest Positive Integer with a Given Smallest Prime Factor
Given a prime number \(P\) and an integer \(N\), find the \(N\)-th smallest positive integer \(X\) (with \(X \le 10^9\)) such that the smallest prime factor of \(X\) is \(P\). A number \(X\) is valid if it is divisible by \(P\) and no prime smaller than \(P\) divides \(X\). In other words, if \(X=P\times k\), then \(k\) must not be divisible by any prime less than \(P\).
You are guaranteed that there exists an answer \(X\) satisfying \(X\le 10^9\).
inputFormat
The input consists of two space-separated integers \(P\) and \(N\), where \(P\) is a prime.
outputFormat
Output the \(N\)-th smallest positive integer \(X\) (with \(X \le 10^9\)) having \(P\) as its smallest prime factor.
sample
2 1
2