A11608 | Vile Grasshoppers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The only line contains two integers $p$ and $y$ $(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 $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.
It immediately follows that there are no valid branches in second sample case.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted