A. Dawid and Bags of Candies

传送门

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;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

稚皓君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值