传送门

题意:

  有 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(数学)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces Round 561(Div 2)题解

    这是一场失败的比赛. 前三题应该是随便搞的. D有点想法,一直死磕D,一直WA.(赛后发现少减了个1……) 看E那么多人过了,猜了个结论交了真过了. 感觉这次升的不光彩……还是等GR3掉了洗掉这次把, ...

  5. Codeforces Round #561 (Div. 2)

    C. A Tale of Two Lands 题意: 给出 n 个数,问有多少点对(x,y)满足 |x-y| ≤ |x|,|y| ≤ |x+y|: (x,y) 和 (y,x) 表示一种答案: 题解: ...

  6. Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)

    A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ...

  7. 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 ...

  8. 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/ ...

  9. Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)

    主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...

随机推荐

  1. UML时序图(Sequence Diagram)学习笔记

    什么是时序图时序图(Sequence Diagram),又名序列图.循序图,是一种UML交互图.它通过描述对象之间发送消息的时间顺序显示多个对象之间的动态协作. 让我们来看一看visio2016对时序 ...

  2. python findall函数

  3. HTML5拖放API实现拖放排序的实例代码

    想要拖放某个元素,必须设置该元素的 draggable 属性为 true,当该属性为 false 时,将不允许拖放.而 img 元素和 a 元素都默认设置了 draggable 属性为 true,可直 ...

  4. Codeforces 439C

    题目链接 比赛时间没能通过==, 只能说明自己代码写的太不严谨咯! 解题思想就是贪心 先判断无解的情况: 1. 奇数不够,因为偶数是无法凑成奇数的 2. 偶数不够,2个奇数可以凑成一个偶数 3. 在奇 ...

  5. linux类库之log4j-LogBack-slf4j-commons-logging

    log4j http://commons.apache.org/proper/commons-logging/ http://logging.apache.org/log4j/2.x/ The Com ...

  6. Directx11教程(49) stencil的应用-镜面反射

    原文:Directx11教程(49) stencil的应用-镜面反射      本教程中,我们利用stencil来实现一个镜面反射效果. 1.首先我们要在D3DClass中增加几个成员变量及函数. I ...

  7. Ceph 之 Background on http frontends

    Background on http frontends -civetweb frontend --thread per connection, requires a lot of threads - ...

  8. PHPCMS快速建站系列之添加单页模版

    单页模板命名:page_xxx.html 以page_开头 在模版所在目录的config.php中添加配置项 'page_xxx.html' => '单网页', 也可以不在config中配置,不 ...

  9. C++异常相关

    使用异常处理,程序中独立开发的各部分能够就程序执行期间出现的问题相互通信,并处理这些问题.C++ 的异常处理中,需要由问题检测部分抛出一个对象给处理代码,通过这个对象的类型和内容,两个部分能够就出现了 ...

  10. du,df区别

    1.记住命令 du:disk Usage -h, --human-readable print sizes in human readable format df:disk free 2.区别 du ...