CodeForces 1166E The LCMs Must be Large
题目链接:http://codeforces.com/problemset/problem/1166/E
说明
- LCM(一个集合) 为这个集合中所有元素的最小公倍数。
- 如果$A \subseteq B,LCM(A) \leq LCM(B)$。
题目大意
给定由 n 个整数组成的集合 A 。现给定 m 组集合,每个集合 Si 都是 A 的一个真子集,求是否存在集合 A 使得对$\forall_{1 \leq i \leq m} \ 不等式LCM(S_i) > LCM(A - S_i)恒成立$。
分析
- 无交集:$LCM(S_i) \geq LCM(A - S_i) \geq LCM(S_j) 和 LCM(S_j) \geq LCM(A - S_j) \geq LCM(S_i)矛盾$,所以只要有两个集合没有交集,A就不存在。
- 有交集:有交集一不一定存在 A 呢?不晓得,只能说可能,反正题目只需要输出可不可能。
代码如下
#include <bits/stdc++.h>
using namespace std; #define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i) #define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl #define LOWBIT(x) ((x)&(-x)) #define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin()) #define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a)) #define MP make_pair
#define PB push_back
#define ft first
#define sd second template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
} template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v)
in >> x;
return in;
} template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
out << "[" << p.first << ", " << p.second << "]" << "\n";
return out;
} inline int gc(){
static const int BUF = 1e7;
static char buf[BUF], *bg = buf + BUF, *ed = bg; if(bg == ed) fread(bg = buf, , BUF, stdin);
return *bg++;
} inline int ri(){
int x = , f = , c = gc();
for(; c<||c>; f = c=='-'?-:f, c=gc());
for(; c>&&c<; x = x* + c - , c=gc());
return x*f;
} typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e18 + ;
const int maxN = 1e4 + ;
const LL ONE = ;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555; struct BitMap{
char bm[maxN >> ]; // 把第 x 位设置为 1
void set(int x){
bm[x >> ] |= 0x80 >> (x & 0x07);
}
// 把第 x 位设置为 1
void clear(int x){
bm[x >> ] &= ~(0x80 >> (x & 0x07));
}
// 获得第 x 位值
bool get(int x){
return bm[x >> ] & (0x80 >> (x & 0x07));
} bool operator& (const BitMap &x) const{
Rep(i, maxN >> ) if(bm[i] & x.bm[i]) return true;
return false;
} bool operator| (const BitMap &x) const{
Rep(i, maxN >> ) if(bm[i] | x.bm[i]) return true;
return false;
}
}; int m, n, s;
BitMap bitMask[];
bool ans = true; int main(){
INIT();
cin >> m >> n;
Rep(i, m) {
cin >> s;
Rep(j, s) {
int x;
cin >> x;
bitMask[i].set(x);
}
} Rep(i, m) {
For(j, i + , m - ) {
if(bitMask[i] & bitMask[j]) continue;
ans = false;
i = m;
break;
}
} if(ans) cout << "possible" << endl;
else cout << "impossible" << endl;
return ;
}
CodeForces 1166E The LCMs Must be Large的更多相关文章
- CF1166E The LCMs Must be Large
CF1166E The LCMs Must be Large 构造趣题 正着推其实很不好推 不妨大力猜结论 如果两两集合都有交,那么一定可以 证明: 1.显然如果两个集合没有交,一定不可以 2.否则给 ...
- Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)
传送门 题意: 有 n 个商店,第 i 个商店出售正整数 ai: Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数: Dora 的对手 Swiper 在第 i 天去 ...
- 【36.86%】【codeforces 558B】Amr and The Large Array
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- codeforces 558B B. Amr and The Large Array(水题)
题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes in ...
- CodeForces 1152F2 Neko Rules the Catniverse (Large Version)
题目链接:http://codeforces.com/problemset/problem/1152/F2 题目大意 见http://codeforces.com/problemset/problem ...
- Codeforces 1166E(思维)
题面 有一个长度为n的序列a,有m次操作.每一次操作一个人选a的一个子集x,另一个人会选x的补集y.且x集合中的数的最小公倍数比y集合中的数的最小公倍数大.现在给出所有x,判断是否有一个序列a满足条件 ...
- 降智严重——nowcoder练习赛46&&codeforces #561 Div2
两场比赛降智不停,熬夜爆肝更掉rating nowcoder: https://ac.nowcoder.com/acm/contest/894#question T1:水题 T2:考虑a和b的子区间! ...
- codeforces631B
Print Check CodeForces - 631B Kris works in a large company "Blake Technologies". As a bes ...
- Codeforces Round #312 (Div. 2)B. Amr and The Large Array 暴力
B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
随机推荐
- luoguP2709 小B的询问 [莫队]
题目描述 小B有一个序列,包含N个1~K之间的整数.他一共有M个询问,每个询问给定一个区间[L..R],求Sigma(c(i)^2)的值,其中i的值从1到K,其中c(i)表示数字i在[L..R]中的重 ...
- STM32嵌入式开发学习笔记(七):串口通信(下)
下面我们进行几个串口通信的实际应用. 实验一:发信实验,让开发板通过串口向电脑发送信息: #include <stdio.h> #include <stm32f10x.h> # ...
- Robotframework之下拉列表select
下拉框控件很常见啊,主要说一下robotframework中怎么玩转下拉框,第一点要注意的就是,别看到下拉的就用select控件去操作,因为很多下拉列表用的不一定就是select控件.robotfra ...
- I/O复用select 使用简介
一:五种I/O模型区分: 1.阻塞I/O模型 最流行的I/O模型是阻塞I/O模型,缺省情形下,所有套接口都是阻塞的.我们以数据报套接口为例来讲解此模型(我们使用UDP而不是TCP作为例子的原 ...
- linux:lrzsz安装
Linux中的lrzsc是linux里可代替ftp上传和下载的程序. yum install lrzsc 没有可用软件包 lrzsc. 这时使用 -y即可安装 centos安装:yum -y inst ...
- kmalloc vs vmalloc
kmalloc分配物理上连续的空间,可以不是整页大小的. vmalloc分配逻辑上连接的空间,可以不是物理上连接的.
- leetcode.字符串.14最长公共前缀-Java
1. 具体题目 编写一个函数来查找字符串数组中的最长公共前缀.如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","fl ...
- node+webpack+vue的环境搭建
一般第一次搭建环境的时候,多多少少还是会出点状况的.这个时候多去百度,看牛人怎么解决,然后跟着尝试,多试几遍还是能解决的. 先说一下我安装的过程吧 1.我一开始按照官网的来搭建,失败了.报错内容是 ...
- python将字典列表导出为Excel文件的方法
将如下的字典列表内容导出为Excel表格文件形式: 关于上图字典列表的写入,请参考文章:https://blog.csdn.net/weixin_39082390/article/details/ ...
- 净心诀---python3生成器
生成器的作用----减少程序运行的内存开销 生成器特点: 1.一个一个的取值,而不是一次性把所有数据创建出来,迭代器中的数据不取不创建2.只能按照顺序取,不能跳过也不能回头3.一个迭代器中的数据只能从 ...