Problem Description
The school set up three elective courses, assuming that these courses are A, B, C. N classes of students enrolled in these courses.
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.
 
Input
The first line of the input gives the number of test cases T; T test cases follow.
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

 
Output
For each test case output one line contains one integer denotes the max number of students who enrolled in at least one course among N classes.
 
Sample Input
2
2
4 5 4 4 3 2 2
5 3 1 2 0 0 0
2
0 4 10 2 3 4 9
6 12 6 3 5 3 2
 
Sample Output
7 15

Hint

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.

 
题意:给出a,b,c,ab,bc,ac,abc的人数,问是否这种情况是否可以,求出在n中给出情况中可以的情况的总人数
简单题,看代码即可。
 #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(容斥简单题)的更多相关文章

  1. HDU 6140 17多校8 Hybrid Crystals(思维题)

    题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...

  2. HDU 6124 17多校7 Euler theorem(简单思维题)

    Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...

  3. 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 ...

  4. hdu1796:容斥入门题

    简单的容斥入门题.. 容斥基本的公式早就知道了,但是一直不会写. 下午看到艾神在群里说的“会枚举二进制数就会容斥”,后来发现还真是这样.. 然后直接贴代码了 #include <iostream ...

  5. HDU How many integers can you find 容斥

    How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. hdu 6169 Senior PanⅡ Miller_Rabin素数测试+容斥

    Senior PanⅡ Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Pr ...

  7. HDU - 4336:Card Collector(min-max容斥求期望)

    In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...

  8. HDU - 5297:Y sequence (迭代&容斥)

    Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hat ...

  9. HDU - 5977 Garden of Eden (树形dp+容斥)

    题意:一棵树上有n(n<=50000)个结点,结点有k(k<=10)种颜色,问树上总共有多少条包含所有颜色的路径. 我最初的想法是树形状压dp,设dp[u][S]为以结点u为根的包含颜色集 ...

随机推荐

  1. mybatis使用@param("xxx")注解传参和不使用的区别

    public interface SystemParameterMapper { int deleteByPrimaryKey(Integer id); int insert(SystemParame ...

  2. leetcode-algorithms-18 4Sum

    leetcode-algorithms-18 4Sum Given an array nums of n integers and an integer target, are there eleme ...

  3. leetcode-algorithms-16 3Sum Closest

    leetcode-algorithms-16 3Sum Closest Given an array nums of n integers and an integer target, find th ...

  4. CO15批次确定,标准的太蛋疼了

    1.批次确定的配置,之前有转过,自己也动手配过,可以是可以,但是蛋疼,用户不愿意去弹出的界面选批次...2.因为这边的批次全部是按年月日+流水生成的,所以在批次确定这里就需要按照批次的号来排序选择了 ...

  5. 配置tomcat允许跨域访问,cors跨域资源共享

    1.导入cors-filter-1.7.jar,java-property-utils-1.9.jar两个jar包 2.在web.xml里配上: <filter> <filter-n ...

  6. InnoDB存储引擎介绍-(6) 二. Innodb Antelope文件格式

    InnoDB存储引擎和大多数数据库一样(如Oracle和Microsoft SQL Server数据库),记录是以行的形式存储的.这意味着页中保存着表中一行行的数据.到MySQL 5.1时,InnoD ...

  7. Fiddler 抓包工具总结【转载】

    原博主连接在文章底部 Fiddler是一个蛮好用的抓包工具,可以将网络传输发送与接受的数据包进行截获.重发.编辑.转存等操作.也可以用来检测网络安全.反正好处多多,举之不尽呀!当年学习的时候也蛮费劲, ...

  8. zzw原创_LIKE与regexp_like中的_及转义符

    1.select table_name from user_tables  where table_name like 'MENU%';查出以下表MENUMENUGGG_131MENU_132MENU ...

  9. Guarding Bananas

    Guarding Bananas Once there was a lazy monkey in a forest. But he loved banana too much. One day the ...

  10. SQL SERVER版本补丁体系及升级

    首先了解几个定义: RTM : 表示 Release to Manufacturing ,这是产品的原始发布版本,当从光盘或 MSDN 下载的默认版本.不过现在下载 SQL Server 版本时,也有 ...