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. 《数据结构与算法分析:C语言描述》复习——第六章“排序”——冒泡排序

    2014.06.17 01:04 简介: 冒泡排序是O(n^2)级别的交换排序算法,原理简单,属于必知必会的基础算法之一. 思路: 排序要进行N轮,每一轮从尾部逐个向前扫描,遇到逆序对就进行交换.确保 ...

  2. android什么时候会产生ANR

    ANR: Application No Response 1.界面操作(按钮点击)等待时间超过5秒 2.HandleMessage 回调函数中执行超过10秒(进行长时间处理不放在主界面,放在另一个线程 ...

  3. Spring整合EhCache详解

    一.EhCache介绍 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认的CacheProvider.Ehcache是一种广泛使用的开 源Java分布 ...

  4. 《Android权威编程指南(The Big Nerd Ranch Guide)(第二版)》12.4挑战练习

    本书第12章是讲解Dialog.12.4挑战练习是在CriminalIntent项目中,再增加一个TimePickerFragment的对话框fragment.通过在CrimeFragment用户界面 ...

  5. 使用Ghost版本Windows7系统下载安装virtualBox和centos7异常解决

    使用Ghost版本Windows7系统下载安装virtualBox和centos7异常解决: 下载安装运行virtualBox时出现获取VirtualBox对象严重错误(如图): 解决方案步骤: 在开 ...

  6. springboot生成表结构

    https://blog.csdn.net/yalishadaa/article/details/59656332

  7. 孤荷凌寒自学python第二十八天python的datetime.date模块

     孤荷凌寒自学python第二十八天python的datetime.date模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.toordinal() 此方法将访问从公元1年1月1日至当 ...

  8. 贪吃蛇StringBuilder 和 定时器

    ConsoleKeyInfo info = Console.ReadKey(); while (true) { if (info.Key == ConsoleKey.UpArrow)//只能输入一次但 ...

  9. jQuery对象转化为DOM对象

    jQuery库本质上还是JavaScript代码,它只是对JavaScript语言进行包装处理,为的是提供更好更方便快捷的DOM处理与开发中经常使用的功能.我们使用jQuery的同时也能混合JavaS ...

  10. Redis、Mongodb、memcache区别在哪里?

    最近在看一本书<php mvc开发实战>看到Redis实战部分,详细介绍了几种缓存的区别和对比,帮助解决这方面的疑惑 Redis适合哪些业务场景?