智商在线检测round。。。

A题维护的最大值。

B题,先判断是否为偶数,不是的话就判断是否存在,不存在就是NO,否则为YES

C题,判断中是否存在,使得,不存在就为NO,不知为何偷懒只判断前14位全排列会WA

D题, 的情况就直接输出

下面讨论,的情况,不妨设显然为偶数,那么取,则有


A

LL t;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    f(sb,1,t){
        LL n,ans=0;
        cin>>n;
        f(i,1,n){
            LL temp;
            cin>>temp;
            ans=max(ans,temp-i);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

B:

LL t,n,last,now,flag;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    f(sb,1,t){
        cin>>n;
        flag=(n&1)?0:1;
        cin>>last;
        f(i,2,n){
            cin>>now;
            if(last>=now)
            flag=1;
            last=now;
        }
        if(flag) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}

C:

LL t, n, temp, a[18];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> t;
    a[1] = 1;
    f(i, 2, 17) a[i] = i * a[i - 1];
    f(sb, 1, t)
    {
        cin >> n;
        LL flag = 1;
        f(i, 1, n)
        {
            cin >> temp;
            LL dd = 0;
            if (flag)
                f(j, 2, i + 1)
                {
                    if (temp % j)
                    {
                        dd = 1;
                        break;
                    }
                }
                if (dd == 0)
                    flag = 0;
                
        }
        if (flag)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}

D:

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    f(sb,1,t){
        cin>>x>>y;
        if(y<x) cout<<x+y<<"\n";
        else if(x==y) cout<<x<<"\n";
        else if(((x+y)>>1)%x==y%((x+y)>>1))cout<<((x+y)>>1)<<"\n";
        else {
            LL m=y-x;
            m=m/x*x;
            x+=m;
            cout<<((x+y)>>1)<<"\n";
        }
    }
    return 0;
}
此文章已被阅读次数:正在加载...更新于