zoukankan      html  css  js  c++  java
  • Codeforces_714_B

    http://codeforces.com/problemset/problem/714/B

    当不同大小整数有1、2个时,肯定成立,3个时,需要判断,大于等于4个,则肯定不成立。

    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    
    long long a [5];
    int main()
    {
        int n;
        cin >> n;
        int num = 0;
        while(n--)
        {
            if(num > 3)
            {
                break;
            }
            long long temp;
            cin >> temp;
            int flag = 1;
            for(int i = 0;i < num;i++)
            {
                if(a[i] == temp)    flag = 0;
            }
            if(flag) a[num++] = temp;
        }
        if(num == 1 || num == 2)    printf("YES
    ");
        else if(num == 3)
        {
            sort(a,a+3);
            if(a[0]+a[2] == 2*a[1]) printf("YES
    ");
            else    printf("NO
    ");
        }
        else
        {
            printf("NO
    ");
        }
    
        return 0;
    }
  • 相关阅读:
    LuoGu P1006 传纸条
    LuoGu P1083 借教室
    动态规划-区间dp-Palindrome Removal
    咕果
    直径问题 Diameter Problems
    Contest 161
    ALBert
    Focal Loss
    Contest 159
    Contest 160
  • 原文地址:https://www.cnblogs.com/zhurb/p/5871441.html
Copyright © 2011-2022 走看看