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圈子里的事儿,或许真 ...
- 写一个quick sort
#include <stdio.h> #include <stdlib.h> //int a[]={1000,10000,9,10,30,20,50,23,90,100,10} ...
- 《Cracking the Coding Interview》——第10章:可扩展性和存储空间限制——题目7
2014-04-24 22:06 题目:搜索引擎问题,如果有一列100台服务器的集群,用来响应查询请求,你要如何设计query分发和cache策略? 解法:query分发可以用计算数字签名并对机器数取 ...
- 【转载】Unity3D研究院之共享材质的巧妙用法(sharedMaterial效率问题)
如果你需要修改模型材质的颜色,或者是修改材质Shader的一些属性, 通常情况是用获取模型的Renderer组件,然后获取它的material属性. 举个简单的例子,修改颜色或者直接更换shader ...
- FlexGrid布局
FlexGrid布局: Grid布局时网格大小是固定的,如果想网格大小不同的界面可以使用FlexGrid布局.FlexGrid是更加灵活的Grid布局.FlexGrid布局类是wx.FlexGridS ...
- PHP excel 设置参数
$objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1); <?php error_ ...
- (转\整)UE4游戏优化 多人大地型游戏的优化(三)GPU的优化
施主分享随缘,评论随心,@author:白袍小道 小道暗语: 1.因为小道这里博客目录没自己整,暂时就用随笔目录结构,所以二级目录那啥就忽略了.标题格式大致都是(原or转) 二级目录 (标题) 2.因 ...
- centos 7 安装codeblocks
CentOS7安装Code::Blocks 在CentOS7上安装Codelocks的过程. 1.安装gcc,需要c和c++两部分,默认安装下,CentOS不安装编译器的,在终端输入以下命令即可yum ...
- 课时5:闲聊之Python的数据类型
目录: 一.引言 二.数据类型 >整型 >浮点型 >布尔类型 三.类型转换 四.获得关于类型的信息 五.课时05课后习题及答案 *********** 一.引言 ********** ...
- 六、vue侦听属性
$watch 实际上无论是 $watch 方法还是 watch 选项,他们的实现都是基于 Watcher 的封装.首先我们来看一下 $watch 方法,它定义在 src/core/instance/s ...