#abc296d. D - M<=ab

D - M<=ab

Score : 400400 points

问题陈述

给定两个正整数 NNMM

找出满足以下两个条件的最小正整数 XX,若不存在这样的整数,则输出 1-1

  • XX 可以表示为两个在闭区间 11NN 内(包括两端点)的整数 aabb 的乘积。这里,aabb 可以是相同的。
  • XX 至少为 MM

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given positive integers NN and MM.
Find the smallest positive integer XX that satisfies both of the conditions below, or print 1-1 if there is no such integer.

  • XX can be represented as the product of two integers aa and bb between 11 and NN, inclusive. Here, aa and bb may be the same.
  • XX is at least MM.

Constraints

  • 1N10121\leq N\leq 10^{12}
  • 1M10121\leq M\leq 10^{12}
  • NN and MM are integers.

Input

The input is given from Standard Input in the following format:

NN MM

Output

Print the smallest positive integer XX that satisfies both of the conditions, or 1-1 if there is no such integer.

Sample Input 1

5 7

Sample Output 1

8

First, 77 cannot be represented as the product of two integers between 11 and 55.
Second, 88 can be represented as the product of two integers between 11 and 55, such as 8=2×48=2\times 4.

Thus, you should print 88.

Sample Input 2

2 5

Sample Output 2

-1

Since 1×1=11\times 1=1, 1×2=21\times 2=2, 2×1=22\times 1=2, and 2×2=42\times 2=4, only 11, 22, and 44 can be represented as the product of two integers between 11 and 22, so no number greater than or equal to 55 can be represented as the product of two such integers.
Thus, you should print 1-1.

Sample Input 3

100000 10000000000

Sample Output 3

10000000000

For a=b=100000a=b=100000 (=105)(=10^5), the product of aa and bb is 1000000000010000000000 (=1010)(=10^{10}), which is the answer.
Note that the answer may not fit into a 3232-bit integer type.

update @ 2024/3/10 12:18:10