zoukankan      html  css  js  c++  java
  • A. Dawid and Bags of Candies ( Codeforces Round #588 (Div. 2) )

    Dawid has four bags of candies. The ii-th of them contains aiai candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?

    Note, that you can't keep bags for yourself or throw them away, each bag should be given to one of the friends.

    Input

    The only line contains four integers a1a1, a2a2, a3a3 and a4a4 (1ai1001≤ai≤100) — the numbers of candies in each bag.

    Output

    Output YES if it's possible to give the bags to Dawid's friends so that both friends receive the same amount of candies, or NO otherwise. Each character can be printed in any case (either uppercase or lowercase).

    Examples
    input
    Copy
    1 7 11 5
    
    output
    Copy
    YES
    
    input
    Copy
    7 3 2 5
    
    output
    Copy
    NO
    
    Note

    In the first sample test, Dawid can give the first and the third bag to the first friend, and the second and the fourth bag to the second friend. This way, each friend will receive 1212 candies.

    In the second sample test, it's impossible to distribute the bags.

     

    分堆会有2-2和1-3 分法,所以坑了一部分人 

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #include <map>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <cmath>
    using namespace std;
    #define ull unsigned long long
    #define lli long long
    #define pq priority_queue<int>
    #define pql priority_queue<ll>
    #define pqn priority_queue<node>
    #define v vector<int>
    #define vl vector<ll>
    #define read(x) scanf("%d",&x)
    #define lread(x) scanf("%lld",&x);
    #define pt(x) printf("%d
    ",(x))
    #define YES printf("YES
    ");
    #define NO printf("NO
    ");
    #define gcd __gcd
    #define out(x) cout<<x<<endl;
    #define over cout<<endl;
    #define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++)
    #define input(k) for (int i = 1; i <= (int)(k); i++)  {scanf("%d",&a[i]) ; }
    #define mem(s,t) memset(s,t,sizeof(s))
    #define ok return 0;
    #define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define mod(x) ((x)%9973)
    #define test cout<<"     ++++++      "<<endl;
    //二叉树
    #define lson rt<<1, l, m
    #define rson rt<<1|1, m+1, r
    //线段树
    #define ls now<<1
    #define rs now<<1|1
    //int dir[6][3] = {0,0,1,0,0,-1,1,0,0,-1,0,0,0,1,0,0,-1,0};
    //int dir[4][2] = {1,0,-1,0,0,1,0,-1}; //单位移动
    //int dir[8][2] = {2,1,2,-1,-2,1,-2,-1,1,2,1,-2,-1,2,-1,-2};
    int t,n,m,k,x,y,col,ex,ey,ans,cnt,ly;
     
    int a[5];;
    int main()
    {
        for(int i=0;i<4;i++)
            cin>>a[i];
        sort(a,a+4);
        if(a[0]+a[3]==a[2]+a[1] || a[0]+a[1]+a[2]==a[3]) {YES;}
        else {NO;}
     
    }
    所遇皆星河
  • 相关阅读:
    【杂文】搞一个对拍程序
    【学习笔记】线段树详解(全)
    【杂文】5亿大质数表(5e8)
    【学习笔记】OI玄学道—代码坑点
    【题解】动态逆序对 [CQOI2011] [P3157] [BZOJ3295] [P1393]
    【题解】永无乡 [HNOI2012] [BZOJ2733] [P3224]
    【题解】晋升者计数 Promotion Counting [USACO 17 JAN] [P3605]
    【题解】古代猪文 [SDOI2010] [BZOJ1951] [P2480]
    【题解】PERIOD
    Navicat Premium 12连接ubuntu18 ,Mysql 5.7.27-0
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11577736.html
Copyright © 2011-2022 走看看