A. Dawid and Bags of Candies
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Dawid has four bags of candies. The i-th of them contains ai 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 a1, a2, a3 and a4 (1≤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
1 7 11 5
Output
YES
Input
7 3 2 5
Output
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 12candies.In the second sample test, it’s impossible to distribute the bags.
题意:输出四个数字代表四份糖果数量判断能否通过移动糖果数量达到糖果相同。它相等的判定方法有两种,一是一份与其他三份相等,二是两两相等。
思路:就简单的相加后判断。
AC代码
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
if ((a == b + c + d) || (b == a + c + d) || (c == a + b + d) || (d == a + b + c) || (a + b == c + d) || (a + c == b + d) || (a + d == b + c))
{
printf("YES\n");
}
else
{
printf("NO\n");
}
return 0;
}