Codeforces - 1166E - The LCMs Must be Large

地址

http://codeforces.com/contest/1166/problem/E

原文地址

https://www.lucien.ink/archives/434

题目

Dora the explorer has decided to use her money after several years of juicy royalties to go shopping. What better place to shop than Nlogonia?

There are nnn stores numbered from 111 to nnn in Nlogonia. The iii-th of these stores offers a positive integer aia_iai​.

Each day among the last mmm days Dora bought a single integer from some of the stores. The same day, Swiper the fox bought a single integer from all the stores that Dora did not buy an integer from on that day.

Dora considers Swiper to be her rival, and she considers that she beat Swiper on day iii if and only if the least common multiple of the numbers she bought on day iii is strictly greater than the least common multiple of the numbers that Swiper bought on day iii.

The least common multiple (LCM) of a collection of integers is the smallest positive integer that is divisible by all the integers in the collection.

However, Dora forgot the values of aia_iai​. Help Dora find out if there are positive integer values of aia_iai​ such that she beat Swiper on every day. You don’t need to find what are the possible values of aia_iai​ though.

Note that it is possible for some values of aia_iai​ to coincide in a solution.

题意

有 nnn 种石头,每个石头有一个未知的权值,有 mmm 天,每天一个整数 kkk 代表这一天拿了 kkk 个石头,接下来是 kkk 个整数,代表石头的下标。

问是否存在一种分配权值的方案,使得每一天拿的所有石头权值的 LCMLCMLCM 都严格大于补集中所有石头权值的 LCMLCMLCM 。

题解

反证法,考虑某一天拿的集合为 DiD_iDi​ ,补集为 SiS_iSi​ ,另一天的集合为 DjD_jDj​ ,补集为 SjS_jSj​ ,且 SiS_iSi​ 严格等于 DjD_jDj​ 。假设题设成立,那么有:

LCM(Di)>LCM(Si)=LCM(Dj)>LCM(Sj)=LCM(Di)LCM(D_i) > LCM(S_i) = LCM(D_j) > LCM(S_j) = LCM(D_i)LCM(Di​)>LCM(Si​)=LCM(Dj​)>LCM(Sj​)=LCM(Di​)

显然矛盾,所以不成立。

考虑另一个问题,假设 AAA 是 BBB 的子集,那么一定存在 LCM(B)≥LCM(A)LCM(B) \ge LCM(A)LCM(B)≥LCM(A) 而且 LCM(B)mod  LCM(A)=0LCM(B) \mod LCM(A) = 0LCM(B)modLCM(A)=0 ,假设 DiD_iDi​ 和 DjD_jDj​ 的交集为空,那么 DjD_jDj​ 一定为 SiS_iSi​ 的真子集,同理,DiD_iDi​ 也是 SjS_jSj​ 的真子集,那么:

LCM(Di)>LCM(Si)≥LCM(Dj)>LCM(Sj)≥LCM(Di)LCM(D_i) > LCM(S_i) \ge LCM(D_j) > LCM(S_j) \ge LCM(D_i)LCM(Di​)>LCM(Si​)≥LCM(Dj​)>LCM(Sj​)≥LCM(Di​)

显然也矛盾,即:任意两天所拿的石头都必须有交集 (1)。

2019年5月22日补充

虽然不满足条件 (1) 一定不能赢,但满足条件 (1) 就一定可以赢吗?答案是不一定。但我们可以通过合理的构造来使得当满足条件 (1) 时是一定全胜的。

如何构造出来一组解呢?根据结论 (1) ,一个显然的想法就是将权值全都集中在有交集的那部分石头上,剩下的全为 111 ,这样一来我方取到的石头的 LCM 一定是严格大于对面的。

更详细一些,我们取出 mmm 个互不相同的素数 p1,p2,…,pm−1,pm{p_1, p_2, \dots, p_{m - 1}, p_m}p1​,p2​,…,pm−1​,pm​ ,令 nnn 个石头的权值为 a1,a2,a3,…,an−1,an{a_1, a_2, a_3, \dots, a_{n - 1}, a_n}a1​,a2​,a3​,…,an−1​,an​ ,初始时 aia_iai​ 均为 111 。假设我们在第 jjj 天访问了 aia_iai​ ,那么我们就令 ai=ai⋅pja_i = a_i \cdot p_jai​=ai​⋅pj​ ,这样一来 pjp_jpj​ 就是 aia_iai​ 的一个因子。

下面来证明这样分配一定是必胜的。我们知道在第 iii 天,我们访问了一个在第 jjj 天访问过的石头,而且这个石头的权值一定是 pjp_jpj​ 的倍数。所以对于每一天 iii ,LCM(Di)=p1p2…pmLCM(D_i) = p_1p_2\dots p_mLCM(Di​)=p1​p2​…pm​ 。另一方面,SiS_iSi​ 并不包含 pip_ipi​ 这个因子,因为 pip_ipi​ 都在 DiD_iDi​ 里,所以 LCM(Si)LCM(S_i)LCM(Si​) 严格小于 LCM(Di)LCM(D_i)LCM(Di​) 。

mmm 的范围只有 505050 ,所以直接 O(nm2)O(nm^2)O(nm2) 暴力判断一下即可。

代码

https://pasteme.cn/8174

#include <bits/stdc++.h>
const int maxm = 57, maxn = int(1e4) + 7;
int m, n;
bool vis[maxm][maxn];
int main() {scanf("%d%d", &m, &n);for (int i = 1, cnt, buf; i <= m; i++) {scanf("%d", &cnt);while (cnt--) scanf("%d", &buf), vis[i][buf] = true;}for (int i = 1; i <= m; i++) {for (int j = 1; j <= m; j++) {bool flag = false;for (int k = 1; k <= n && !flag; k++) {if (vis[i][k] && vis[j][k]) flag = true;}if (!flag) return 0 * puts("impossible");}}puts("possible");return 0;
}

Codeforces - 1166E - The LCMs Must be Large相关推荐

  1. CF1166E The LCMs Must be Large

    CF1166E The LCMs Must be Large 构造趣题 正着推其实很不好推 不妨大力猜结论 如果两两集合都有交,那么一定可以 证明: 1.显然如果两个集合没有交,一定不可以 2.否则给 ...

  2. Codeforces Round #561 (Div. 2)-E. The LCMs Must be Large

    地址:https://codeforces.com/contest/1166/problem/E 思路:比赛时,D,E两题都不会写,然后抱着试一试的态度对E分析,对于第i天,若其他天与该天是没有重合的 ...

  3. E. The LCMs Must be Large(思维)

     题目链接:https://codeforces.com/contest/1166/problem/E 题目大意:首先是n个数,然后有m次划分,每一次输入第一部分(下标),第一部分的补给为第二部分.然 ...

  4. codeforces1166E. The LCMs Must be Large

    题目链接 琪亚娜世界第一可爱 现在有两个人,Swiper和Dora,在m天中,每天Swiper先从n个位置上取一些数,剩下的就是Dora的数,要求在这个m天中,每天Swiper取出的数的lcm都要比D ...

  5. Potato的暑期训练day#1题解 ——毒瘤构造

    Potato的暑期训练day#1 --毒瘤构造 题目链接: A.https://vjudge.net/problem/HDU-1214 B.https://vjudge.net/problem/Cod ...

  6. CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)

    CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段) 树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且 ...

  7. codeforces contest 1166 E. The LCMs Must be Large---思维

    题目链接:https://codeforces.com/contest/1166/problem/E 题解: 代码: #include<bits/stdc++.h> using names ...

  8. Codeforces Round #300 A. Cutting Banner 水题

    A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...

  9. 【Codeforces】Round #375 (Div. 2)

    Position:http://codeforces.com/contest/723 我的情况 啊哈哈,这次raiting肯定要涨,接受过上次的教训,先用小号送肉,大号都是一发切,重回蓝咯 结果... ...

最新文章

  1. /xiaolei.php|martin_十步解决Php Utf-8编码(转贴)
  2. 第07课:【实战】调试Redis准备工作
  3. 【ARM】Tiny4412裸板编程之MMU(段1M)
  4. 机器学习进阶-优化的近邻算法
  5. 网络OS显神威 认识Linux远程桌面控制
  6. 【主动声呐】——匹配滤波器
  7. 数据库里的小知识❤️
  8. python安装后如何使用-python运行环境,python安装后如何使用
  9. android10下载更新功能,Android 10部分新功能曝光 感觉越来越暗黑
  10. 使用dd命令制作ISO镜像U盘启动盘
  11. 西门子S7-200的PLC,CPU224XP的模拟量接线怎样接
  12. ERStudio如何显示entity的tableName(表名的英文)和defaultColumnName(英文字段名)
  13. 计算机网络施工组织设计,06网络系统施工组织设计方案.doc
  14. hadoop功能测试
  15. 武大计算机导师蔡贤涛,CAD模型在线集成与离线集成关键技术研究
  16. java clh_AQS基础——多图详解CLH锁的原理与实现
  17. 快进来看看!!!C语言——扫雷小游戏(递归展开无雷区)
  18. 版权领域的发展趋势对版权保护有哪些重要意义?
  19. Linux 环境下部署Hexagon SDK 开发环境
  20. windows中文件夹有小锁是什么意思,文件夹小锁怎么去掉

热门文章

  1. 赛题类型 Web、Crypto、Pwn、Reverse、Misc 各是指什么意思?
  2. 1060显卡用什么软件测试,科技 篇七:有了它,GTX1060竟变智商检测卡!
  3. 软考高级系统架构设计师系列之:深入掌握软考高级系统架构设计师考试的知识分布点,轻松应对高级系统架构设计师考试
  4. Android 10调用相机拍照
  5. VScode远程连接服务器解决办法
  6. 世博版新君威提车作业
  7. C++——流和输入输出
  8. 网络营销实战课-好用的工具推荐
  9. 通用的JS表单验证插件代码
  10. oracle ocm认证概述