CF937B.Vile Grasshoppers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.

The pine's trunk includes several branches, located one above another and numbered from 22 to yy . Some of them (more precise, from 22 to pp ) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch xx can jump to branches .

Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.

In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.

输入格式

The only line contains two integers pp and yy (2<=p<=y<=109)(2<=p<=y<=10^{9}) .

输出格式

Output the number of the highest suitable branch. If there are none, print -1 instead.

输入输出样例

  • 输入#1

    3 6
    

    输出#1

    5
    
  • 输入#2

    3 4
    

    输出#2

    -1
    

说明/提示

In the first sample case grasshopper from branch 22 reaches branches 22 , 44 and 66 while branch 33 is initially settled by another grasshopper. Therefore the answer is 55 .

It immediately follows that there are no valid branches in second sample case.

首页