CF937B.Vile Grasshoppers

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

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 2 to y. Some of them (more precise, from 2 to p) 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 x 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.

今天天气晴好,正是爬上附近松树、饱览风景的大好时机。

这棵松树的树干上分布着若干枝杈,自下而上依次排列,编号从 22 到 yy。其中一部分枝杈(确切地说,是从 22 到 pp)被一群微小而讨厌的蚱蜢占据着,而你正与它们交战。这些蚱蜢以惊人的跳跃能力著称:位于枝杈 xx 上的蚱蜢可以跳到枝杈 。

考虑到这一点,你明智地决定选择一个不会被任何蚱蜢干扰的枝杈。同时,你还希望尽可能爬得高些,因为高处的景色实在令人叹为观止。

换言之,你的目标是找出所有蚱蜢均无法到达的最高枝杈;若不存在这样的枝杈,则报告“不可能”。

输入格式

The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109).

唯一一行包含两个整数 pp 和 yy(2 ≤ p ≤ y ≤ 1092 \le p \le y \le 10^9)。

输出格式

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

输出最高合适分支的编号。如果没有合适的分支,则输出 −1-1。

输入输出样例

  • 输入#1

    3 6

    输出#1

    5
  • 输入#2

    3 4

    输出#2

    -1

说明/提示

In the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.

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

在第一个样例中,位于分支 2 上的蚱蜢可以到达分支 2、4 和 6,而分支 3 最初已被另一只蚱蜢占据。因此答案为 5。

由此立即可知,在第二个样例中不存在合法的分支。

输入解题思路,AI测评打分。不知道怎么写?

首页