Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.

You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.

Solve the problem to show that it's not a NP problem.

Input

The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).

Output

Print single integer, the integer that appears maximum number of times in the divisors.

If there are multiple answers, print any of them.

Examples

Input
19 29
Output
2
Input
3 6
Output
3

Note

Definition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html

The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.

The second example: from 3 to 6 these numbers are divisible by 3: {3, 6}.

思路:分两种情况,

1、R-L<=1 的输出L或者R其中的任意一个。

2、R-L>=2 那么这个区间里 能被2整除的数一定是最多的数中之一个,因为相邻的两个数必然有一个是偶数,那么偶数就可以被2整除。

我的AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/ int main()
{
ll l,r;
cin>>l>>r;
if(l==r)
{
cout<<l<<endl;
}else
{
if(r-l>=)
{
cout<<<<endl;
}else
{
cout<<l<<endl;
}
}
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}

Fake NP CodeForces - 805A (思维)的更多相关文章

  1. Codeforces Round #411 A. Fake NP

    A. Fake NP time limit per test   1 second memory limit per test   256 megabytes   Tavak and Seyyed a ...

  2. Codeforces 805A/B/C

    A. Fake NP 传送门:http://codeforces.com/contest/805/problem/A 本题是一个数学问题. 给定两个正整数l,r(l≤r),对于区间[l..r]上的任一 ...

  3. Codeforces805 A. Fake NP 2017-05-05 08:30 327人阅读 评论(0) 收藏

    A. Fake NP time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  4. 【codeforces 805A】Fake NP

    [题目链接]:http://codeforces.com/contest/805/problem/A [题意] 问你在l..r这个区间内的所有数字: 对于每个数的因子; 出现次数最多的是哪一个; [题 ...

  5. CodeForces 805A Fake NP

    直觉. 一段区间中,肯定是$2$的倍数最多,因为区间长度除以$2$得到的数字最大.但只有$1$个数字的时候需要特判. #include <cstdio> #include <cmat ...

  6. Codeforces 424A (思维题)

    Squats Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Statu ...

  7. Codeforces 1060E(思维+贡献法)

    https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间 ...

  8. Queue CodeForces - 353D (思维dp)

    https://codeforces.com/problemset/problem/353/D 大意:给定字符串, 每一秒, 若F在M的右侧, 则交换M与F, 求多少秒后F全在M左侧 $dp[i]$为 ...

  9. B. Case of Fake Numbers( Codeforces Round #310 (Div. 2) 简单题)

    B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

随机推荐

  1. python五十七课——正则表达式(边界字符)

    演示匹配锚字符(边界字符)^:从字符串头部开始匹配,在开启多行模式下(re.M),可以尝试匹配每一行的头部数据$:从字符串尾部开始匹配,在开启多行模式下(re.M),可以尝试匹配每一行的尾部数据A:从 ...

  2. MSSQL Server 数据库备份还原常用SQL语句及注意

    1.备份数据库 backup database db_name to disk='d:\db_name.bak' with format --通过使用with format可以做到覆盖任何现有的备份和 ...

  3. YOLO2 (2) 测试自己的数据

    Windos10 linux同样过程 现有问题: 本文过程在linux下类似,可以正常通过.windons下,运行python脚本出现问题,无法正常输出0001.txt(标定文件),所以只能使用lin ...

  4. 【JDK和Open JDK】平常使用的JDK和Open JDK有什么区别(转)

    文章转自https://www.cnblogs.com/sxdcgaq8080/p/7487369.html 注意到这个问题,是在CentOS7上安装JDK的时候,查找相关的资料,发现安装JDK之前都 ...

  5. shell编程之测试和判断

    一.测试 程序运行中经常需要根据实际情况来运行特定的命令或代码段.比如判断某个文件或目录是否存在,如果文件或目录不存在,可能首先创建文件或目录.举例说,要判断文件/var/log/mlocate文件是 ...

  6. nginx环境搭建

    nginx安装步骤 安装nginx[root@insure opt]# yum install nginx启动nginx [root@insure opt]# service nginx start ...

  7. Mysql windows版本的安装

    一.mysql官网下载 下载安装包 MySQL Community Server (GPL)--> 选用zip版本的 二.安装 解压mysql的安装包. 将bin目录配置到环境变量中.(即环境变 ...

  8. 不存在具有键“xxxId”的“IEnumerable<SelectListItem>”类型的 ViewData 项

    项目中的某个页面,在访问时出现以下错误: 不存在具有键“xxxId”的“IEnumerable<SelectListItem>”类型的 ViewData 项 具体的场景说明如下: 一个编辑 ...

  9. Mac安装LNMP环境,升级php7

    Mac安装nginx+mysql+php 安装nginx比较麻烦,要安装pcre       ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre ...

  10. POJ3714 Raid 分治/K-D Tree

    VJ传送门 简要题意:给出两个大小均为\(N\)的点集\(A,B\),试在\(A\)中选择一个点,在\(B\)中选择一个点,使得它们在所有可能的选择方案中欧几里得距离最小,求出这个距离 下面给出的两种 ...