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 (1≤ai≤1001≤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\n",(x))
#define YES printf("YES\n");
#define NO printf("NO\n");
#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;}

}

原文地址:https://www.cnblogs.com/Shallow-dream/p/11577736.html

时间: 2024-08-29 17:20:30

A. Dawid and Bags of Candies ( Codeforces Round #588 (Div. 2) )的相关文章

B. Ania and Minimizing (Codeforces Round #588 (Div. 2) )

Ania has a large integer SS. Its decimal representation has length nn and doesn't contain any leading zeroes. Ania is allowed to change at most kk digits of SS. She wants to do it in such a way that SS still won't contain any leading zeroes and it'll

CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))

题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候  如果对于一条边 a->b  如果dis1[a] <dis2[a]  那么选择这条边就选择   l  因为这条边对于s1有利 如果两个起点都选择了这条边  则说明s1 赢定了,所以要让他们尽量走这条,所以边权越小越好.跑完之后检测 如果  dis1[f]<dis2[f] 那么 就赢了. 接下来判断能不能平局

小蒟蒻初次CF滚粗+爆炸记 (Codeforces Round #466 Div.2)

比赛链接:http://codeforces.com/blog/entry/57981 小蒟蒻今天初次在ZCDHJ张大佬的带领下,打了一场CF (张大佬cnblogs链接:https://www.cnblogs.com/ZCDHJ)' 英文完全看不懂,后面几题直接放弃,各位dalao请见谅 T1: 题目链接:http://codeforces.com/contest/940/problem/A 题目大意: 给你一个n个数的集合,要求你删掉若干数,其中最大的差不应该超过d,求最小删除量. (小蒟蒻

B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

B. Ohana Cleans Up Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she swe

【CodeForces】841C. Leha and Function(Codeforces Round #429 (Div. 2))

[题意]定义函数F(n,k)为1~n的集合中选择k个数字,其中最小数字的期望. 给定两个数字集A,B,A中任意数字>=B中任意数字,要求重组A使得对于i=1~n,sigma(F(Ai,Bi))最大. [算法]数学结论+数学期望+排序 [题解]很无奈,这题放在div2 C,难以推导的期望公式,广为人知的结论,容易观察样例得出的做法,都体现了这道题的不合理性. F(n,k)=(n+1)/(k+1) 公式推导可能触及我的知识盲区了QAQ 得到公式后,显然要求k尽可能小,n尽可能大,经验告诉我们随着两数

A. Kyoya and Photobooks(Codeforces Round #309 (Div. 2))

A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photo

D2 Equalizing by Division (hard version) &amp;&amp;D1 Equalizing by Division (easy version) (easy version)(Codeforces Round #582 (Div. 3))

The only difference between easy and hard versions is the number of elements in the array. You are given an array aa consisting of nn integers. In one move you can choose any aiai and divide it by 22 rounding down (in other words, in one move you can

C. Almost Equal ( Codeforces Round #580 (Div. 2) )

output standard output You are given integer nn. You have to arrange numbers from 11 to 2n2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every nn consecutive numbers on the circle write the

A Joysticks (Codeforces Round 345 (Div 2) )

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each m