[CF1166E] The LCMs Must be Large - 构造

给定由 \(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");
}

上一篇:bzoj 2694: Lcm


下一篇:Beautiful numbers