多校6 HDU-6106 Classes 容斥原理
来源:互联网 发布:超级玛丽mac版 编辑:程序博客网 时间:2024/06/01 10:39
题目链接:
HDU-6106
大意:
有三个科目 A,B,C 。已知一个班级选修情况 ,分别为选择 A 的人数,选择 B 的人数,选择 C 的人数,选择 AB 的人数,选择 BC 的人数,选择 AC 的人数,选择 ABC 的人数,
给出 N 个班级,而且有的班级数据是错误的(无法计算),求这些班级里总人数最多为多少。
思路:
画一个韦恩图,每个小块都可以计算出来,着每个小块的人数都必须为自然数。
代码实现;
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define mem(s,t) memset(s,t,sizeof(s))#define D(v) cout<<#v<<" "<<v<<endl#define inf 0x3f3f3f3f#define getans (DIS(x,y,x1,y1)+DIS(x,y,x2,y2))//#define LOCALinline void read(int &x){ x=0;char p=getchar(); while(!(p<='9'&&p>='0'))p=getchar(); while(p<='9'&&p>='0')x*=10,x+=p-48,p=getchar();}int main() {#ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif int t; read(t); while(t--){ int n; read(n); int ans=0; while(n--){ int a,b,c,d,e,f,g; scanf("%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g); int ret=0; if(a-d-f+g<0) continue; if(b-d-e+g<0) continue; if(c-e-f+g<0) continue; if(d-g<0 || e-g<0 || f-g<0) continue; ret=(a+b+c-d-e-f+g); ans=max(ans,ret); } printf("%d\n",ans); } return 0;}
阅读全文
0 0
- 多校6 HDU-6106 Classes 容斥原理
- hdu 6106 Classes(容斥)
- hdu 6106 Classes 2017多校第六场1011签到题 容斥原理
- 【容斥原理】HDU 4135
- hdu 4135 容斥原理
- hdu 4336 容斥原理
- hdu 1695 容斥原理
- hdu 4407 容斥原理
- HDU 1796 容斥原理
- hdu 1796 容斥原理
- hdu 4135 (容斥原理)
- HDU 1695 容斥原理
- HDU 3929 容斥原理
- HDU 4135 容斥原理
- hdu 4407 容斥原理
- hdu 4135 容斥原理
- hdu 4135 容斥原理
- hdu 4135(容斥原理)
- hbuilder常用快捷键
- Java-I/O流
- Python可视化seaborn练习题
- 训练总结8.10
- Hue与hadoop的集成配置
- 多校6 HDU-6106 Classes 容斥原理
- python学习笔记之003.py
- POJ 2312 Battle City
- styleneat规范css编写工具
- YARN核心部件解读
- ansible入门
- 使用通配符* There is no Action mapped for namespace [/] and action name [user_add] associated with conte
- 算法铺子之排序---堆排序(一)
- python爬虫三:获取一个网易用户的所有图片(selenium+phantomjs)