A. ACM ICPC
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.

After practice competition, participant number i got a score of ai. Team score is defined as sum of scores of its participants. High school management is interested if it's possible to build two teams with equal scores. Your task is to answer that question.

Input

The single line contains six integers a1, ..., a6 (0 ≤ ai ≤ 1000) — scores of the participants

Output

Print "YES" (quotes for clarity), if it is possible to build teams with equal score, and "NO" otherwise.

You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

Examples
input
1 3 2 1 2 1
output
YES
input
1 1 1 1 1 99
output
NO
Note

In the first sample, first team can be composed of 1st, 2nd and 6th participant, second — of 3rd, 4th and 5th: team scores are1 + 3 + 1 = 2 + 1 + 2 = 5.

In the second sample, score of participant number 6 is too high: his team score will be definitely greater.

【题意】:存在某三个和另外三个相等输出YES,否则输出NO

【分析】:暴力

【代码】:

#include <bits/stdc++.h>

using namespace std;
const int maxn = ; int main()
{
int a[],sum[];
memset(sum,,sizeof(sum));
for(int i=;i<=;i++)
{
cin>>a[i];
if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} if(a[]+a[]+a[]==a[]+a[]+a[])
{
printf("YES\n");
return ;
} }
printf("NO\n");
return ;
}

我的傻逼代码

#include <bits/stdc++.h>

using namespace std;
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int a[],sum=; int main()
{
for(int i=;i<;i++)
{
cin>>a[i];
sum+=a[i];
}
for(int i=;i<;i++)
{
for(int j=i+;j<;j++)
{
for(int k=j+;k<;k++)
{
if(*(a[i]+a[j]+a[k])==sum)
{
printf("YES\n");
return ;
}
}
}
}
printf("NO\n");
}

枚举

#include <bits/stdc++.h>

using namespace std;

int main() {
int a[];
for(int i = ; i < ; i++) cin >> a[i];
sort(a, a + );
do{
if((a[] + a[] + a[]) == (a[] + a[] + a[])){
cout << "YES";
return ;
}
}while(next_permutation(a, a + ));
cout << "NO";
return ;
}

next_permutation的妙用

最新文章

  1. LINQ系列:LINQ to SQL Select查询
  2. 关于实现手机端自动获取天气的demo
  3. &lt;转&gt;linux crontab 定时任务
  4. FineUI疑难杂症
  5. YUV422/YUV420播放
  6. testNG中@Factory详解
  7. android 使用两个surfaceview 在摄像机画面上绘图
  8. 提高MySQL数据库查询效率的几个技巧(转载)
  9. PHP自学4——通过函数将数组数据输出到html的Table标签中(使用函数的例子)
  10. c++中,size_typt, size_t, ptrdiff_t 简介
  11. stormzhang的推荐!
  12. Object lifetime
  13. 使用Ansible进行项目的自动部署(Tomcat、Weblogic)
  14. ES6常用语法(上)
  15. MySQL 权限相关
  16. 解决y7000笔记本ubuntu18.04下 休眠挂起后唤醒花屏
  17. mysql数据库修改数据表引擎的方法
  18. 【坑】https证书链不完整的坑
  19. HDU 1348 Wall 【凸包】
  20. 通过GeneXus如何快速构建微服务架构

热门文章

  1. 将有效慢日志转存到数据库v2
  2. Jenkins拾遗--第五篇-git插件填坑
  3. 《Cracking the Coding Interview》——第17章:普通题——题目10
  4. Hyper-V 安装Windows 2008,08 R2,12 R2 无网卡驱动的解决办法
  5. Leetcode with Python -&gt; Sort
  6. 【现代程序设计】homework-02
  7. 在jsp页面中使用jstl标签
  8. 根文件系统制作、NFS配置与安装及利用NFS挂载根文件系统
  9. JavaScript要理解闭包先了解词法作用域
  10. 《R语言实战》读书笔记--第三章 图形初阶(一)