首页 > 其他 > 详细

[CF1166E] The LCMs Must be Large - 构造

时间:2020-04-05 09:41:38      阅读:55      评论:0      收藏:0      [点我收藏+]

给定由 \(n\) 个整数组成的集合 \(A\)。现给定 \(m\) 组集合,每个集合 \(S_i\) 都是 \(A\) 的一个真子集(这里的集合描述为 \(A\) 中元素下标集合),求是否存在集合 \(A\) 使得对 \(\forall_{1 \leq i \leq m}\) 不等式 \(LCM(S_i) > LCM(A - S_i)\) 恒成立。

Solution

如果存在两个集合没有交集,设为 \(S,T\),则 \(LCM(S)> LCM(A-S) \ge LCM(T)\),破坏了对称性,则一定无解

否则我们给每个集合安排一个质数 \(p_i\),设用过的所有质数集合为 \(P\),设 \(\prod S\) 是整数集合 \(S\) 的广义积,那么对于集合 \(i\),其 \(LCM\)\(\prod P\),而其补集一定不大于 \(\prod P-\{ p_i \}\),于是一定存在解

#include <bits/stdc++.h>
using namespace std;

bitset <10001> bs[55];

int n,m,k,t;

signed main() {
    ios::sync_with_stdio(false);
    cin>>m>>n;
    int fg=1;
    for(int i=1;i<=m;i++) {
        cin>>k;
        while(k--) {
            cin>>t;
            bs[i][t]=1;
        }
        for(int j=1;j<i;j++) if((bs[i]&bs[j]).count()==0) fg=0;
    }
    cout<<(fg?"possible":"impossible");
}

[CF1166E] The LCMs Must be Large - 构造

原文:https://www.cnblogs.com/mollnn/p/12635808.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!