http://codeforces.com/problemset/problem/937/B

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.

Input

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

Output

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

Examples
input

Copy
3 6
output
5
input

Copy
3 4
output
-1
Note

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.

水题

// 去吧!皮卡丘! 把AC带回来!
// へ     /|
//   /\7    ∠_/
//   / │   / /
//  │ Z _,< /   /`ヽ
//  │     ヽ   /  〉
//  Y     `  /  /
//  イ● 、 ●  ⊂⊃〈  /
//  ()  へ    | \〈
//   >ー 、_  ィ  │ //
//   / へ   / ノ<| \\
//   ヽ_ノ  (_/  │//
//    7       |/
//    >―r ̄ ̄`ー―_
//**************************************
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define ri register int
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) {
return min(min(a, b), min(c, d));
}
template <class T> inline T max(T a, T b, T c, T d) {
return max(max(a, b), max(c, d));
}
#define scanf1(x) scanf("%d", &x)
#define scanf2(x, y) scanf("%d%d", &x, &y)
#define scanf3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define scanf4(x, y, z, X) scanf("%d%d%d%d", &x, &y, &z, &X)
#define pi acos(-1)
#define me(x, y) memset(x, y, sizeof(x));
#define For(i, a, b) for (ll i = a; i <= b; i++)
#define FFor(i, a, b) for (ll i = a; i >= b; i--)
#define bug printf("***********\n");
#define mp make_pair
#define pb push_back
const int maxn = 3e5 + ;
const int maxx = 1e6 + ;
// name*******************************
ll p, y;
// function****************************** //***************************************
int main() {
cin >> p >> y;
bool flag = true;
FFor(i, y, p + ) {
flag = true;
for (ll j = ; j <= p && j * j <= i; j++) {
if (i % j == ) {
flag = false;
break;
}
}
if (flag) {
cout << i;
return ;
}
}
cout<<-; return ;
}

B. Vile Grasshoppers的更多相关文章

  1. Codeforces Round #467 (Div. 2) B. Vile Grasshoppers

    2018-03-03 http://codeforces.com/problemset/problem/937/B B. Vile Grasshoppers time limit per test 1 ...

  2. Codeforces 937.B Vile Grasshoppers

    B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #467 (Div. 2) B. Vile Grasshoppers[求去掉2-y中所有2-p的数的倍数后剩下的最大值]

    B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. CodeForces937B:Vile Grasshoppers(素数性质)

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

  5. A - Vile Grasshoppers

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

  6. CF937B Vile Grasshoppers

    Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. Codeforces Round #467 (div.2)

    Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...

  8. codeforce round #467(div.2)

    A. Olympiad 给出n个数,让你找出有几个非零并且不重复的数 所以用stl的set //#define debug #include<stdio.h> #include<ma ...

  9. 【codeforces】【比赛题解】#937 CF Round #467 (Div. 2)

    没有参加,但是之后几天打了哦,第三场AK的CF比赛. CF大扫荡计划正在稳步进行. [A]Olympiad 题意: 给\(n\)个人颁奖,要满足: 至少有一个人拿奖. 如果得分为\(x\)的有奖,那么 ...

随机推荐

  1. python中面向切片编程(AOP)和装饰器

    @函数名(类的描述符)相当于fuc = decorator(fuc) 装饰器: def deco(fuc): print('============') return fuc @deco def fo ...

  2. A Complete Tutorial to Learn Data Science with Python from Scratch

    A Complete Tutorial to Learn Data Science with Python from Scratch Introduction It happened few year ...

  3. 利用GDAL从内存中直接解析图像数据

    对于网络数据源,调度中可以把数据写入本地,然后读取本地数据格式进行影像的解析(地形有时候也用tif等格式). 此种方式会每次调度进行不必要的IO开销和时间花费. GDAL提供了相应的接口,直接从内存中 ...

  4. reportConfig.xml两种数据源连接的配置方式

     在reportConfig.xml配置文件中,我们提供了两种数据源连接的配置方式,分别如下: 1.jndi数据源配置(即:在dataSource中配置) 此配置适用于在j2ee的服务器中配置了j ...

  5. Ubuntu 安装ipython

    操作步骤安装ipythonsudo apt-get install ipython 安装ipython[notebook]终端输入以下命令: sudo apt-get install ipython- ...

  6. Redis redis-trib集群配置

    redis文档:http://doc.redisfans.com/ 参考:https://www.cnblogs.com/wuxl360/p/5920330.html http://www.cnblo ...

  7. winform listbox增加鼠标双击事件

    在Form.Designer.cs文件中对于listBox处理: listBox.MouseDoubleClick += new system.Windows.Forms.MouseEventHand ...

  8. Mysql中的delimiter详解

    初学mysql时,可能不太明白delimiter的真正用途,delimiter在mysql很多地方出现,比如存储过程.触发器.函数等. 学过oracle的人,再来学mysql就会感到很奇怪,百思不得其 ...

  9. 6.HTML速查模块

    1.HTML 基本文档 <!DOCTYPE html> <html> <head> <title>文档标题</title> </hea ...

  10. Windows ->> 解决Windows 10下面无法多用户同时远程桌面

    解决Windows 10下面无法多用户同时远程桌面 https://pc4u.org/how-to-allow-multiple-rdp-sessions-windows-10-without-mod ...