zoukankan      html  css  js  c++  java
  • [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");
    }
    
    
  • 相关阅读:
    并发编程
    进程的介绍
    操作系统详解
    进程的粗略理解
    打印进度条
    FTP上传下载文件(面向对象版)
    socket套接字
    FTP上传下载文件(函数简易版)
    osi七层协议 Open System Interconnection
    __str__和__repr__的区别
  • 原文地址:https://www.cnblogs.com/mollnn/p/12635808.html
Copyright © 2011-2022 走看看