2017 Multi-University Training Contest - Team 6 Classes
2017-08-18 17:23
399 查看
http://acm.hdu.edu.cn/showproblem.php?pid=6106
1.AB,AC,BC的人数应该是不小于ABC的人数;
2.A不小于AB,AC,B不小于AB,BC,C不小于AC,BC。
3.A不小于AB+AC−ABC,B不小于AB+BC−ABC,C不小于AC+BC−ABC。
只要满足这所有的条件,那么这个班级的数据就肯定是正确的,最后A+B+C+ABC−AB−AC−BC即为这个班级的人数
题意:
给出选A,B,C,AB,AC,BC,ABC课程的人数,来确定班级里的人数,其中有一些数据是错误的,但保证有一组数据是正确的,最后要求出数据完全正确的班级最多的人数。思路:
根据容斥定理,在正确的情况下,1.AB,AC,BC的人数应该是不小于ABC的人数;
2.A不小于AB,AC,B不小于AB,BC,C不小于AC,BC。
3.A不小于AB+AC−ABC,B不小于AB+BC−ABC,C不小于AC+BC−ABC。
只要满足这所有的条件,那么这个班级的数据就肯定是正确的,最后A+B+C+ABC−AB−AC−BC即为这个班级的人数
代码:
#include<bits/stdc++.h> using namespace std; int main(){ int n,T; int a,b,c,ab,bc,ac,abc; while(~scanf("%d",&T)){ while(T--){ scanf("%d",&n); int ans = 0; while(n--){ scanf("%d %d %d %d %d %d %d",&a,&b,&c,&ab,&bc,&ac,&abc); if(a >= ab && a >= ac && b >= ab && b >= bc && c >= bc && c >= ac && ab >= abc && bc >= abc && ac >= abc && a >= (ab + ac - abc) && b >= (ab + bc - abc) && c >= (bc + ac - abc)){ int temp = a + b + c + abc - ab - bc - ac; ans = max(ans,temp); } } printf("%d\n",ans); } } }
相关文章推荐
- 【2017 Multi-University Training Contest - Team 6】Classes
- 2017 Multi-University Training Contest - Team 6 1011 Classes
- HDU - 6098 Inversion (2017 Multi-University Training Contest - Team 6)
- 2017 Multi-University Training Contest - Team 6 1003 Inversion
- HDU-6103 Kirinriki - 2017 Multi-University Training Contest - Team 6(尺取)
- 2017 Multi-University Training Contest - Team 7:hdu6124、Euler theorem
- 2017 Multi-University Training Contest - Team 7:1010. Just do it(组合数?)
- 2017 Multi-University Training Contest - Team 6
- HDU-6129 Just do it - 2017 Multi-University Training Contest - Team 7(规律、杨辉三角、组合数奇偶性)
- 2017 Multi-University Training Contest - Team 10 1008-Monkeys(快速读入模板实例)
- HDU-6181 Two Paths(2017 Multi-University Training Contest - Team 10)
- 2017 Multi-University Training Contest - Team 10 HDU-6172:Array Challenge
- 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
- hdoj 6063(2017 Multi-University Training Contest - Team 3) RXD and math
- hdu 6034 Balala Power!(贪心)( 2017 Multi-University Training Contest - Team 1 )(无耻之sort)
- 2017 Multi-University Training Contest - Team 1 1003 Colorful Tree
- hdu 6047 Maximum Sequence(2017 Multi-University Training Contest - Team 2)
- hdu 6045 Is Derek lying?(2017 Multi-University Training Contest - Team 2)
- hdu 6053 莫比乌斯反演函数的利用 2017 Multi-University Training Contest - Team 2
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)