Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)
题意:
有 n 个商店,第 i 个商店出售正整数 ai;
Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数;
Dora 的对手 Swiper 在第 i 天去了 Dora 未去的商店购买了 n-si 个数;
问在这m天里,是否存在序列a,使得这 m 天都满足 LCM(Dora购买的数) > LCM(Swiper购买的数);
题解:
参考自(戳)
①如果存在两天,在这两天中得到的数字集合不存在交集,那么肯定是无解的。
②如果任意两天之间都存在交集时,一定有解(还是不太理解)。
AC代码:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+; int n,m;
bitset<maxn>b;
vector<bitset<maxn> >vs; char *Solve()
{
for(int i=;i < vs.size();++i)
for(int j=;j < vs.size();++j)
if(!(vs[i]&vs[j]).any())
return "impossible";
return "possible";
}
int main()
{
scanf("%d%d",&m,&n);
for(int i=;i <= m;++i)
{
int tot,s;
scanf("%d",&tot);
b.reset();
for(int j=;j <= tot;++j)
{
scanf("%d",&s);
b.set(s);
}
vs.push_back(b);
}
puts(Solve()); return ;
}
此处代码用到了一个STL中的一个骚操作bitset<>,详解戳这里;
这个操作是我在看大神代码中看到的,tql;
STL也太强大了叭qwq!
Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)的更多相关文章
- Codeforces Round #561 (Div. 2) C. A Tale of Two Lands
链接:https://codeforces.com/contest/1166/problem/C 题意: The legend of the foundation of Vectorland talk ...
- Codeforces Round #561 (Div. 2) B. All the Vowels Please
链接:https://codeforces.com/contest/1166/problem/B 题意: Tom loves vowels, and he likes long words with ...
- Codeforces Round #561 (Div. 2) A. Silent Classroom
链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlo ...
- Codeforces Round 561(Div 2)题解
这是一场失败的比赛. 前三题应该是随便搞的. D有点想法,一直死磕D,一直WA.(赛后发现少减了个1……) 看E那么多人过了,猜了个结论交了真过了. 感觉这次升的不光彩……还是等GR3掉了洗掉这次把, ...
- Codeforces Round #561 (Div. 2)
C. A Tale of Two Lands 题意: 给出 n 个数,问有多少点对(x,y)满足 |x-y| ≤ |x|,|y| ≤ |x+y|: (x,y) 和 (y,x) 表示一种答案: 题解: ...
- Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)
A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ...
- Codeforces Round #561 (Div. 2) A Tale of Two Lands 【二分】
A Tale of Two Lands 题目链接(点击) The legend of the foundation of Vectorland talks of two integers xx and ...
- Codeforces Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学
C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
随机推荐
- Python中输入和输出(打印)数据
一个程序要进行交互,就需要进行输入,进行输入→处理→输出的过程.所以就需要用到输入和输出功能.同样的,在Python中,怎么实现输入和输出? Python3中的输入方式: Python提供了 inpu ...
- 理解nodejs的module
module 在 Node.js 模块系统中,每个文件都视为独立的模块,node在运行某个模块儿时会生成一个module对象 Module { id: '.', exports: 2, parent: ...
- 写GULP遇到的ES6问题详解
Gulp.js 是一个自动化构建工具,开发者可以使用它在项目开发过程中自动执行常见任务.最近复习一下gulp一些基本的写法,在写了一些简单的uglify,rename,concat,clean的处理之 ...
- Python数据分析与展示[第三周](pandas数据特征分析单元8)
数据理解 基本统计 分布/累计统计 数据特征 数据挖掘 数据排序 操作索引的排序 .sort_index() 在指定轴上排序,默认升序 参数 axis=0 column ascending=True ...
- 51nod1040 矩阵相乘结果的判断
给出三个N*N的矩阵A, B, C,问A * B是否等于C?Input第1行,1个数N.(0 <= N <= 500)第2 - N + 1行:每行N个数,对应矩阵A的元素.(0 <= ...
- 编程语言分类及python所属类型
编程语言分类及python所属类型 编程语言主要从以下几个角度为进行分类:编译型和解释型.静态语言和动态语言.强类型定义语言和弱类型定义语言. 编译和解释的区别是什么? 编译器是把源程序的每一条语句都 ...
- 【JZOJ4761】【NOIP2016提高A组模拟9.7】鼎纹
题目描述 输入 输出 样例输入 2 3 4 4 2 1100 0110 1100 10 01 10 00 2 2 2 2 11 11 01 10 样例输出 YES NO 数据范围 解法 由于鼎纹中的第 ...
- pl/sql进阶——例外处理
在pl/sql的执行过程中发生异常时系统所作的处理称为一个例外情况(exception).通常例外情况的种类有三种: ①预定义的oracle例外情况,oracle预定义的例外情况大约有24个,对于这种 ...
- 序列化类型为“System.Data.Entity.DynamicProxies..."对象时检测到循环引用
这是因为EF外键引起的序列化问题. 解决方案: context.Configuration.ProxyCreationEnabled = false; 这里我用的是一个基类控制器用于被继承 返回EF实 ...
- [React Native]获取网络状态
使用React Native,可以使用NetInfo API获取手机当前的各个网络状态. componentWillMount() { NetInfo.fetch().done((status)=&g ...