Fake NP (Codeforces

来源:互联网 发布:玩dnf网络冲突怎么办 编辑:程序博客网 时间:2024/05/18 01:08

题目链接:

http://codeforces.com/problemset/problem/805/A
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

题目大意:

输入两个数,输出 以这两个数为边界的区间内 所有数 出现次数最多的 因子(除1外),如果有多种情况,输出任一个。

解题思路:

在一个区间内,偶数的个数大于其它类型数的个数。但还需要分两种情况:第一种情况:如果输入的两个数相等,那么输出这两个数中的任一个即可;第二种情况:输出 2

代码:

#include<iostream>using namespace std;int main(){    long long int l,r;    while(cin>>l>>r)    {        if(l==r)            cout<<l<<endl;        else            cout<<2<<endl;    }    return 0;}


原创粉丝点击