#411 div2 A. Fake NP

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

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/2的偶数,但剩下一半奇数的不会存在一个相同的因数,所以答案为2。有奇数个数字时同理。但应注意l==r时,答案为l or r。

 

代码:

#include <cstdio>
int main(){
 int l,r;
 scanf("%d%d",&l,&r);
 if(l==r) printf("%d\n",l);
 else printf("2\n");
 return 0;
}

posted @ 2017-08-15 10:22  LMissher  阅读(93)  评论(0)    收藏  举报