HDU 6106 17多校6 Classes(容斥简单题)
2017-08-11 10:07
369 查看
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
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
[align=left]Sample Output[/align]
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中给出情况中可以的情况的总人数
简单题,看代码即可。
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.
[align=left]Input[/align]
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
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
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
[align=left]Sample Output[/align]
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=0; 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 0; }
相关文章推荐
- HDU 6106 Classes (简单集合运算 17多校第六场)
- HDU 6106 Classes【简单思维】
- hdu 6106 Classes(容斥)
- hdu 6106.Classes
- HDU 6106 Classes (水题)
- 2017 多校训练第六场 HDU 6106 Classes
- Hdu-5792 World is Exploding(简单容斥)
- hdu 6106 Classes
- 【HDU】4135 Co-prime(容斥原理简单应用 质因子的分解)
- HDU 1796How many integers can you find(简单容斥定理)
- HDU 4451 简单容斥
- HDU - 6106 Classes
- 多校6 HDU-6106 Classes 容斥原理
- 简单容斥定理-hdu-1796-How many integers can you find
- HDU - 6106 Classes(阅读题)
- HDU 6106 Classes【水题】
- HDU 6124 17多校7 Euler theorem(简单思维题)
- 2017杭电多校第六场 1011 (勉强算容斥吧)HDU 6106
- hdu 6106 Classes 2017多校第六场1011签到题 容斥原理
- HDU 6106 Classes 【】