Codeforces Round #445 A. ACM ICPC【暴力】
2 seconds
256 megabytes
standard input
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.
The single line contains six integers a1, ..., a6 (0 ≤ ai ≤ 1000) — scores of the participants
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").
1 3 2 1 2 1
YES
1 1 1 1 1 99
NO
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【暴力】的更多相关文章
- Codeforces 890A - ACM ICPC 暴力
A. ACM ICPCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputst ...
- Codeforces Round #445
ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...
- 【Codeforces Round #445 (Div. 2) A】ACM ICPC
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 三重循环 [代码] #include <bits/stdc++.h> using namespace std; int ...
- Educational Codeforces Round 8 A. Tennis Tournament 暴力
A. Tennis Tournament 题目连接: http://www.codeforces.com/contest/628/problem/A Description A tennis tour ...
- Educational Codeforces Round 1 A. Tricky Sum 暴力
A. Tricky Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem ...
- Codeforces Round #445 Div. 1
A:每次看是否有能走回去的房间,显然最多只会存在一个,如果有走过去即可,否则开辟新房间并记录访问时间. #include<iostream> #include<cstdio> ...
- Educational Codeforces Round 8 B. New Skateboard 暴力
B. New Skateboard 题目连接: http://www.codeforces.com/contest/628/problem/A Description Max wants to buy ...
- Codeforces Round #253 (Div. 2)B(暴力枚举)
就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...
- 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 ...
随机推荐
- 《1024伐木累》-BUG的通用解决办法
本周月侠出场,一番侠骨柔情,或许你会为丽姐担忧,或许你也很想知道,发现了一个不该发现的秘密,月侠的未来究竟会怎样,但是一切都只是一个开头,伴随故事成长,伴随故事了解时事,尤其是IT圈子里的事儿,或许真 ...
- 玩转Node.js(一)
玩转Node.js(一) 在说Node.js之前,我们先来说说js,如果你也曾开发过前端,那么你一定接触到了这个叫JavaScript有趣的东西,而对于JavaScript,你只会基本的操作——为we ...
- 常用模块(time)
import time # data = time.time() # 获取时间戳# data = time.localtime() # 获取操作系统时间,也称本地时间,可传入时间戳# data = t ...
- (原)Unreal Shader模块(一): 着色创建
一.着色加载 这里说的Shader是编译后的文件或内存 源码说明 --------------------------------------------------------------- ...
- ehcache + spring 整合以及配置说明 ,附带整合问题 (已解决)
新做的项目,因为流量不大 就是一个征信平台,高峰流量不多,但缓存是必须的,cache到server上就可以,不需要额外的memcache.redis之类的东西. 但是遇到一个大坑,事情是这样的: 通过 ...
- Android记事本09
昨天: Activity的数据传递. 今天: 从Activity中返回数据 请求码和返回码的作用 遇到的问题: 无.
- Javascript 基础总结
一.预处理 console.log(global); // undefined var global = 'global'; console.log(global); // global functi ...
- Spark on Yarn——spark1.5.1集群配置
写在前面: spark只是一种计算框架,如果要搭建集群要依托与一定的组织模式. 目前来说,Spark集群的组织形式有三种: 1. Standalone:使用akka作为网络IO组件,mast ...
- BZOJ4031 [HEOI2015]小Z的房间 【矩阵树定理 + 高斯消元】
题目链接 BZOJ4031 题解 第一眼:这不裸的矩阵树定理么 第二眼:这个模\(10^9\)是什么鬼嘛QAQ 想尝试递归求行列式,发现这是\(O(n!)\)的.. 想上高斯消元,却又处理不了逆元这个 ...
- 在有道词典程序文件夹发现一个后缀名为sql的数据库(SQLite)
缘起 在清理电脑磁盘的时候,看一看各安装文件夹有占用了多大容量,发现有道词典居然达140MB了,于是进去看看. 发现个有趣的文件:XXX.sql. 首先我们看一看它的安装文件夹的结构: Dict └─ ...