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. js字符串转日期兼容性

    今天遇到个bug,安卓上是好的,ios就不行.然后我就把可能用到的值都打印出来,发现日期比较一项在苹果机上就显示false,而谷歌浏览器是true.突然回忆起以前开发遇到过类似的问题,都是出在字符串转 ...

  2. Leetcode 116

    /** * Definition for binary tree with next pointer. * struct TreeLinkNode { * int val; * TreeLinkNod ...

  3. MIR7预制发票扣除已经预制的数量(每月多次预制,未即时过账)

    业务场景见抬头,有没有标准的解决方案就不说了,也没去考虑... 这个增强还是SAP老表提供的,感谢,省了不少时间. INCLUDE:LMR1MF6S 最后的位置 ENHANCEMENT ZMIR7_0 ...

  4. ThinkPHP3的使用

    1. 初始目录 7d 根目录 ├─Application 应用目录(空) ├─Public 资源文件目录 ├─ThinkPHP 框架目录 └─index.php 入口文件 2. 入口文件 // 应用入 ...

  5. spring boot 之如何在两个页面之间传递值(转)

    原文地址:spring boot 之如何在两个页面之间传递值 问题:页面之间的跳转,通常带有值的传输,但是,在现在比较流行的SPRING MVC WEB 开发模型中,设计机制导致页面之间的直接接跳转和 ...

  6. ActiveMQ producer 流量控制

    http://activemq.apache.org/producer-flow-control.html 翻译: 流量控制是指:如果broker检测到destination的内存限制.temp文件限 ...

  7. 使用Swagger2构建强大的RESTful API文档(1)(二十二)

    由于Spring Boot能够快速开发.便捷部署等特性,相信有很大一部分Spring Boot的用户会用来构建RESTful API.而我们构建RESTful API的目的通常都是由于多终端的原因,这 ...

  8. JXL生成Excel,并提供下载(1:生成Excel)

    public String exportExcel(long id) { String preeReviewName = "文件名"; String filePath = 路径名; ...

  9. awk使用教程

    gawk - pattern scanning and processing language 基本用法:gawk [options] 'program' FILE ... program:PATTE ...

  10. leetcode python 005

    ##  给定字符串,寻找最长回文子串##  单回文,双回文 def findh(s):    ## 单回文    ld,l=[],len(s)    if len(s)<3:        re ...