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 ------------------------------------------------ ...
随机推荐
- Directx11教程(57) 环境映射
原文:Directx11教程(57) 环境映射 建好skydome后,如果我们想让其中的某个物体,比如那个球体来映射出周围环境的蓝天白云(不包括自己附近的物体),该怎么做呢?此时可以把这个 ...
- Directx11教程(52) 实例(instancing)的简单应用
原文:Directx11教程(52) 实例(instancing)的简单应用 有些时候,我们需要在场景中渲染大量的重复的物体,比如体育场中的观众,森林里面的树木等等,这些物体具有相似的形状,比如很多树 ...
- python Python程序的架构
- 简单的Jquery焦点图切换效果
利用Jquery,优雅的实现焦点图切换 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...
- Linux进程管理(三、 线程)
// ---- refer glibc, pthread_create.c ----// int __pthread_create_2_0 (newthread, attr, start_routin ...
- KiCad EDA 过孔是否可以开窗?
KiCad EDA 过孔是否可以开窗? 和传统的商业 EDA 不同,KiCad EDA 的过孔默认就是盖绿油. 在 KiCad 的过孔界面没有任何可以设置的地方,这也有一个好处,不过考虑过孔是否盖油. ...
- UITextField 自定义clearButton背景色
一个鸡贼的解决方案,适用于自定义clearButton的样式,直接修改背景图即可 1. 实现基于UITextField的category并添加如下方法及声明 - (void)setLightStyle ...
- jq获取浏览器可视窗口的高度
<script> var window_height = $(window).height(); </script>
- oracle函数的分类
v 单行函数:对每一行输入值进行计算,得到相应的计算结果,返回给用户,也就是说,每行作为一个输入参数,经过函数计算得到每行的计算结果. 比如select length(ename) from emp ...
- MUI - 引导页制作
引导页制作 本文的引导页和[官方的引导页示例](https://github.com/dcloudio/mui/blob/master/examples/hello-mui/examples/guid ...