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 ------------------------------------------------ ...
随机推荐
- vs dump调试
1. dump文件和pdb文件的匹配问题 >> 发布二进制文件时生成的pdb文件一定要保留,只有当发布的二进制文件和pdb文件是同时生成的才好正确调试. 2. dump文件和pdb文件放在 ...
- c++中的c_str()函数
//c_str()是为了与C语言兼容,把c++中string类型的字符串返回首地址使用 #include <iostream>#include <string.h>using ...
- DTcms设置 IIS6.0设置url重写导致editor上传全部失效
1.修改iis的重写规则为htm 2.修改后台后缀为htm 解决
- nodeJs学习-17 博客案例
源码:智能社视频20节课件 const express=require('express'); const static=require('express-static'); const cookie ...
- js获取url制定的某个参数
<script>function getURLParam(strParamName, url) { var strReturn = ""; var strH ...
- beanstalkd 启动跟停止
启动命令: nohup /usr/bin/beanstalkd -l xxx.xxx.xxx.xxx -p 11300 & >> /dev/null 2>&1 正常启 ...
- 命名实体识别学习笔记——使用Ltp
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/xuewenstudy/article/d ...
- 【IOS】异常捕获 拒绝闪退 让应用从容的崩溃 UncaughtExceptionHandler
尽管大家都不愿意看到程序崩溃,但可能崩溃是每一个应用必须面对的现实.既然崩溃已经发生.无法阻挡了.那我们就让它崩也崩得淡定点吧. IOS SDK中提供了一个现成的函数 NSSetUncaughtExc ...
- HZOJ Permutation
输出原序列有45分…… 字典序最小可以和拓扑序联系起来. 根据原来的题意不是很可做,于是对原序列求逆,令q[p[i]]=i; 那么就成功将题意转化:相邻元素值的差大于等于k时可以交换,使序列字典序最小 ...
- LeetCode91 Decode Ways
题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: ' ...