• Fake NP CodeForces


    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), '', 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=1000010;
    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>=2)
            {
                cout<<2<<endl;
            }else
            {
                cout<<l<<endl;
            }
        }
        return 0;
    }
    
    inline void getInt(int* p) {
        char ch;
        do {
            ch = getchar();
        } while (ch == ' ' || ch == '
    ');
        if (ch == '-') {
            *p = -(getchar() - '0');
            while ((ch = getchar()) >= '0' && ch <= '9') {
                *p = *p * 10 - ch + '0';
            }
        }
        else {
            *p = ch - '0';
            while ((ch = getchar()) >= '0' && ch <= '9') {
                *p = *p * 10 + ch - '0';
            }
        }
    }

    本博客为本人原创,如需转载,请必须声明博客的源地址。 本人博客地址为:www.cnblogs.com/qieqiemin/ 希望所写的文章对您有帮助。
  • 相关阅读:
    Android内存优化5 了解java GC 垃圾回收机制3
    一起刑事案件法庭辩护 z
    辩护技巧总结——律师在刑事辩护中应注意的几个问题 z
    证据对抗、证据链标准 z
    里德九步审讯法 z
    WCF服务在高并发情况下报目标积极拒绝的异常处理 z
    C#EasyHook例子C# Hook 指定进程C#注入指定进程 z
    玄机论坛Socket类库源码 当前版本 2.6.3 更新日期:10-09/2015 z
    庭审全程文字实录 z
    庭审精彩语录整理 z
  • 原文地址:https://www.cnblogs.com/qieqiemin/p/10246772.html
Copyright © 2020-2023  润新知