HDU 6106 17多校6 Classes(容斥简单题)
Now the school wants to count the number of students who enrolled in at least one course in each class and records the maximum number of students.
Each class uploaded 7 data, the number of students enrolled in course A in the class, the number of students enrolled in course B, the number of students enrolled in course C, the number of students enrolled in course AB, the number of students enrolled in course BC, the number of students enrolled in course AC, the number of students enrolled in course ABC. The school can calculate the number of students in this class based on these 7 data.
However, due to statistical errors, some data are wrong and these data should be ignored.
Smart you must know how to write a program to find the maximum number of students.
Each case begins with one line with one integer N, indicates the number of class.
Then N lines follow, each line contains 7 data: a, b, c, d, e, f, g, indicates the number of students enrolled in A, B, C, AB, BC, AC, ABC in this class.
It's guaranteed that at least one data is right in each test case.
Limits
T≤100
1≤N≤100
0≤a,b,c,d,e,f,g≤100
In the second test case, the data uploaded by Class 1 is wrong. Because we can't find a solution which satisfies the limitation. As for Class 2, we can calculate the number of students who only enrolled in course A is 2, the number of students who only enrolled in course B is 6, and nobody enrolled in course C, the number of students who only enrolled in courses A and B is 1, the number of students who only enrolled in courses B and C is 3, the number of students who only enrolled in courses A and C is 1, the number of students who enrolled in all courses is 2, so the total number in Class 2 is 2 + 6 + 0 + 1 + 3 + 1 + 2 = 15.
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- #include<queue>
- #include<map>
- #include<vector>
- #include<cmath>
- #include<cstring>
- using namespace std;
- int main()
- {
- int T,n,ans;
- int a,b,c,ab,bc,ac,abc;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d",&n);
- ans=;
- while(n--)
- {
- scanf("%d%d%d%d%d%d%d",&a,&b,&c,&ab,&bc,&ac,&abc);
- if(ab<=a&&ab<=b&&bc<=b&&bc<=c&&ac<=a&&ac<=c
- &&abc<=ab&&abc<=bc&&abc<=ac
- &&ac+ab-abc<=a&&ac+bc-abc<=c&&ab+bc-abc<=b)
- {
- if(a+b+c-ab-bc-ac+abc>ans)
- ans=a+b+c-ab-bc-ac+abc;
- }
- }
- printf("%d\n",ans);
- }
- return ;
- }
HDU 6106 17多校6 Classes(容斥简单题)的更多相关文章
- HDU 6140 17多校8 Hybrid Crystals(思维题)
题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...
- HDU 6124 17多校7 Euler theorem(简单思维题)
Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...
- HDU 3130 17多校7 Kolakoski(思维简单)
Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This seq ...
- hdu1796:容斥入门题
简单的容斥入门题.. 容斥基本的公式早就知道了,但是一直不会写. 下午看到艾神在群里说的“会枚举二进制数就会容斥”,后来发现还真是这样.. 然后直接贴代码了 #include <iostream ...
- HDU How many integers can you find 容斥
How many integers can you find Time Limit: 12000/5000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 6169 Senior PanⅡ Miller_Rabin素数测试+容斥
Senior PanⅡ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Pr ...
- HDU - 4336:Card Collector(min-max容斥求期望)
In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...
- HDU - 5297:Y sequence (迭代&容斥)
Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hat ...
- HDU - 5977 Garden of Eden (树形dp+容斥)
题意:一棵树上有n(n<=50000)个结点,结点有k(k<=10)种颜色,问树上总共有多少条包含所有颜色的路径. 我最初的想法是树形状压dp,设dp[u][S]为以结点u为根的包含颜色集 ...
随机推荐
- leetcode-algorithms-29 Divide Two Integers
leetcode-algorithms-29 Divide Two Integers Given two integers dividend and divisor, divide two integ ...
- 元类应用ORM实现
首先看下一个简单的例子 # 需求 import numbers class Field: pass class IntField(Field): # 数据描述符 def __init__(self, ...
- 前端web的图标的样式
- 前端基础之CSS的引入+HTML标签选择器+CSS操作属性
clear:left/ringt属性 CSS:语法形式上由选择器+以及一条或多条声明组成:选择器查找到指定的html标签后,使用css属性设置html标签的样式: ...
- Qt_自定义菜单
一.右键菜单 右键菜单实现:通过重写contextMenuEvent(QContextMenuEvent *event)事件,QMenu+QAction即可完美实现! 重写voidcontextMen ...
- Net Core2.0 升级到.Net Core 2.1
1. 安装新 .Net Core SDK 2.1 2. 升级VS.net 到15.7, 这个版本极其不好用,IIS打中文会自动退出,但现在也没办法降级了.只能等微软打补丁. 3. 对于面向 ASP.N ...
- python(5)之集合
集合是一个无序的,不重复的数据组合,它的主要作用如下: 1.去重,把一个列表变为集合就自动去重了 2.关系测试,测试两组数据之间的交集.并集.差集等 常用操作如下: #集合的操作 list_1={1, ...
- linux basic test
Linux 1◆ 提供连接 2◆ connection baidu.com 3◆ vm tools install Reboot
- Cmd管理员运行
Cmd管理员运行 C:\Windows\System32
- javascript void函数
<a href="javascript:doTest2();void(0);">here</a> 但这儿的void(0)究竟是何含义呢? Javascrip ...