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的妙用

Codeforces Round #445 A. ACM ICPC【暴力】的更多相关文章

  1. Codeforces 890A - ACM ICPC 暴力

    A. ACM ICPCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputst ...

  2. Codeforces Round #445

    ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...

  3. 【Codeforces Round #445 (Div. 2) A】ACM ICPC

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 三重循环 [代码] #include <bits/stdc++.h> using namespace std; int ...

  4. Educational Codeforces Round 8 A. Tennis Tournament 暴力

    A. Tennis Tournament 题目连接: http://www.codeforces.com/contest/628/problem/A Description A tennis tour ...

  5. Educational Codeforces Round 1 A. Tricky Sum 暴力

    A. Tricky Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem ...

  6. Codeforces Round #445 Div. 1

    A:每次看是否有能走回去的房间,显然最多只会存在一个,如果有走过去即可,否则开辟新房间并记录访问时间. #include<iostream> #include<cstdio> ...

  7. Educational Codeforces Round 8 B. New Skateboard 暴力

    B. New Skateboard 题目连接: http://www.codeforces.com/contest/628/problem/A Description Max wants to buy ...

  8. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

  9. Educational Codeforces Round 19 E. Array Queries(暴力)(DP)

    传送门 题意 给出n个数,q个询问,每个询问有两个数p,k,询问p+k+a[p]操作几次后超过n 分析 分块处理,在k<sqrt(n)时,用dp,大于sqrt(n)用暴力 trick 代码 #i ...

随机推荐

  1. CSS3 3D圆形设计教程

    http://www.htmleaf.com/ziliaoku/qianduanjiaocheng/201502061338.html

  2. 【UVA10655】 Contemplation! Algebra

    题目 给定 \(p = a + b\) 和 \(q = ab\) 和 \(n\),求 \(a ^ n + b ^ n\). $0\le n\lt 2^{63} $ 分析 大水题. 先考虑 \(n\) ...

  3. 【java下午茶】12306的双人票

    明天下午就要和客户谈需求了,今天还在列车上假象着明天的情景,由于这是一个旅游的项目,所以想尽可能设计得人性化一些. 不过有件很不爽的事情就是和老公的位子是分开的,虽然我们订的是连坐号.就这个问题也是我 ...

  4. 更改maven本地仓库地址

    1.进入maven安装conf文件中,编辑settings.xml文件,新增图中的圈出的内容(我想要存放的地址是D:\HMY\m2\repository) 2.复制settings.xml文件至D:\ ...

  5. Python 快速部署安装所需模块

    需求 我们需要在拷给别人或者提交至服务器也用同样的模块,好保持和开发的一样,所以我们需要自己手动写配置模块信息. 方法 在根目录下创建一个 requirements.txt  文件 里面写 模块名== ...

  6. 自动using和Layout

    一.自动using 1. Model  文件夹添加 Person类,在view文件夹下web.config文件,将namespace加入,cshtml文件就不需要添加@model引用:         ...

  7. NodeJs03 express框架 Todo商城

    前言 由于NodeJs本身的异步非阻塞特性和对http的天然支持,所以使用NodeJs编写高性能,可伸缩的Web服务器非常简单.开发完整的Web服务器还需要路由,错误处理,请求拦截,请求和响应的解析, ...

  8. 按住ALT键复制

    按住ALT键可以选择一块进行操作. 这个在数据库in查询.代码中批量删除头部一些东西特别方便.

  9. Android React Native组件的生命周期及回调函数

    熟悉android的童鞋应该都清楚,android是有生命周期的,其很多组件也是有生命周期.今天小编和大家分享的React Native组件的生命周期,还不了解的童鞋,赶紧来围观吧 在android开 ...

  10. LACP学习笔记

    LACP学习笔记 来源: https://blog.csdn.net/zhengmx100/article/details/53893902 参考文档:download.h3c.com.cn/down ...