9311: ABC296 —— D - M<=ab
[Creator : ]
Description
You are given positive integers $N$ and $M$.
Find the smallest positive integer $X$ that satisfies both of the conditions below, or print $-1$ if there is no such integer.
- $X$ can be represented as the product of two integers $a$ and $b$ between $1$ and $N$, inclusive. Here, $a$ and $b$ may be the same.
- $X$ is at least $M$.
Find the smallest positive integer $X$ that satisfies both of the conditions below, or print $-1$ if there is no such integer.
- $X$ can be represented as the product of two integers $a$ and $b$ between $1$ and $N$, inclusive. Here, $a$ and $b$ may be the same.
- $X$ is at least $M$.
Input
The input is given from Standard Input in the following format:
```
$N$ $M$
```
```
$N$ $M$
```
Output
Print the smallest positive integer $X$ that satisfies both of the conditions, or $-1$ if there is no such integer.
Constraints
- $1\leq N\leq 10^{12}$
- $1\leq M\leq 10^{12}$
- $N$ and $M$ are integers.
- $1\leq M\leq 10^{12}$
- $N$ and $M$ are integers.
Sample 1 Input
5 7
Sample 1 Output
8
First, 7 cannot be represented as the product of two integers between 1 and 5.
Second, 8 can be represented as the product of two integers between 1 and 5, such as 8=2×4.
Thus, you should print 8.
Second, 8 can be represented as the product of two integers between 1 and 5, such as 8=2×4.
Thus, you should print 8.
Sample 2 Input
2 5
Sample 2 Output
-1
Since 1×1=1, 1×2=2, 2×1=2, and 2×2=4, only 1, 2, and 4 can be represented as the product of two integers between 1 and 2, so no number greater than or equal to 5 can be represented as the product of two such integers.
Thus, you should print -1.
Thus, you should print -1.
Sample 3 Input
100000 10000000000
Sample 3 Output
10000000000
For $a=b=100000 (=10^5)$, the product of $a$ and $b$ is $10000000000 (=10^{10})$, which is the answer.