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)恒成立$. 分…
CF1166E The LCMs Must be Large 构造趣题 正着推其实很不好推 不妨大力猜结论 如果两两集合都有交,那么一定可以 证明: 1.显然如果两个集合没有交,一定不可以 2.否则给每个集合Si乘上一个质数pi,pi互不相同 由于两两有交,那么一个集合Si的LCM一定是所有p的乘积,而其补集一定没有pi这个质数,一定小于 所以充分必要性得证 证毕. #include<bits/stdc++.h> #define reg register int #define il inli…
传送门 题意: 有 n 个商店,第 i 个商店出售正整数 ai: Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数: Dora 的对手 Swiper 在第 i 天去了 Dora 未去的商店购买了 n-si 个数: 问在这m天里,是否存在序列a,使得这 m 天都满足 LCM(Dora购买的数) > LCM(Swiper购买的数): 题解: 参考自(戳) ①如果存在两天,在这两天中得到的数字集合不存在交集,那么肯定是无解的. ②如果任意两天之间都存在交集时,一定有…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array…
题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr d…
题目链接:http://codeforces.com/problemset/problem/1152/F2 题目大意 见http://codeforces.com/problemset/problem/1152/F1,此题 n 最大能到 109. 分析 在 F1 的基础上,我们发现 dp[i + 1] 数组的每个值均可以通过 dp[i] 数组的有限几个数求得,而 dp[i + 2] 数组的每个值也均可以通过 dp[i + 1] 数组相同位置的有限几个数求得,于是我们可以考虑用矩阵快速幂来求 dp…
题面 有一个长度为n的序列a,有m次操作.每一次操作一个人选a的一个子集x,另一个人会选x的补集y.且x集合中的数的最小公倍数比y集合中的数的最小公倍数大.现在给出所有x,判断是否有一个序列a满足条件. 分析 考虑不满足条件的情况:假如子集\(x_i\)和\(x_j\)完全不相交,会出现矛盾 因为\(gcd(x_i)>gcd(a-x_i),gcd(x_j)>gcd(a-x_j)\),我们又知道\(x_j=a-x_i\),因此上式可以化为\(gcd(x_i)>gcd(x_j),gcd(x_…
两场比赛降智不停,熬夜爆肝更掉rating nowcoder: https://ac.nowcoder.com/acm/contest/894#question T1:水题 T2:考虑a和b的子区间!排序+二分 T3:降智傻x题. 不能看做黑色多了p个,蓝色多了(1-p)个,然后拿走球是按照比例的 因为实际多了一个占比就是不一样的. f[i]i轮之后黑球数量.f[i]=....f[i-1]矩阵快速幂或者等比数列求和 T4:降智贪心题 二分t,每个时刻有出现次数d, 只要不断选择花费精力最小的时刻…
Print Check CodeForces - 631B Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already…
B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/problem/B Description Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care abou…
[Codeforces 163D]Large Refrigerator (DFS+剪枝) 题面 已知一个长方体的体积为V,三边长a,b,c均为正整数,求长方体的最小表面积S V以质因数分解的形式给出 分析 暴力做法很容易想到,按照质因子的指数枚举a,b,然后就能直接算出c,然后就可以得到表面积S=2(ab+bc+ac) 考虑优化: 1.搜索顺序:保证\(a \geq b \geq c\),枚举质因数时从大到小枚举a,从小到大枚举b 2.可行性剪枝:枚举a的时候保证\(a^3 \leq V\),枚…
题目链接:http://codeforces.com/problemset/problem/558/B 题目意思:给出一个序列,然后找出出现次数最多,但区间占用长度最短的区间左右值. 由于是边读入边比较,因此问题最关键的是,记录每个数第一次出现的位置,即左值.因为要保证次数是出现最多,因此需要一个cnt[]数组来记录出现次数.然后当最多出现次数与当前cnt[x]次数相同时,要选择区间较短的,再更新左右区间值. 赛中短路竟然想不出来~~~泪啊~~泪啊- >_< #include <iost…
Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some…
B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't c…
B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't c…
本题的主要算法就是区间更新和区间求和: 可以用线段树和树状数组来做: 感觉线段树写的太麻烦了,看到官方题解上说可以用树状数组做,觉得很神奇,以前用过的树状数组都是单点维护,区间求和的: 其实树状数组还可以区间维护,单点求值:和区间维护,区间求和的: 详情请见博客. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #define maxn 4000010 #define…
题意:有一个数组.如今要削减它的尺寸.数组中同样元素的个数的最大值为数组的魅力值,要求削减后魅力值不能降低,同一时候要尽可能的把尺寸减到最小 分析:水题,主要是不要想复杂了.还有就是沉下心来做 代码: #include<iostream> #include<cstring> #include<algorithm> #define INF 1000000007 #define max(a,b) a>b?a:b using namespace std; int n,a…
树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c); 1.单点改动 : c[x] += y; 相应的函数是 change(x, y); 2.求前缀和 :  相应的函数是 int sum(x) 两种操作的复杂度都是O(logn) 模板例如以下: int c[N], maxn; inline int Lowbit(int x){return x&(-x…
题意:给定平面上N个点,问是否存在三角形,其面积为S. 思路:选择Y轴,枚举这个Y轴,面积大小只与|y-Y|有关,然后二分,具体的可以先去做BZOJ3707. 具体的: 1,先对点排序,X坐标为第一关键字,Y坐标为第二关键字,从小到大排序. 2,得到C(N,2)条直线,按照它们的斜率为关键字(叉积排序比较准确),从小到大排序. 3,二分答案,对当前直线,我们只处理线段左边(相对来说)的点,左边的点距离当前“Y轴”具有单调性. 而得到当前直线的两个点,相对于下一条直线,其相对位置会发生改变. 简单…
题目链接:点击打开链接 题意:给定n*m的二维平面 w个操作 int mp[n][m] = { 0 }; 1.0 (x1,y1) (x2,y2) value for i : x1 to x2 for j : y1 to y2 mp[i][j] += value; 2.1 (x1, y1) (x2 y2) ans1 = 纵坐标在 y1,y2间的总数 ans2 = 横坐标不在x1,x2间的总数 puts(ans1-ans2); more format: for i : 1 to n for j :…
题意 有nnn个点,每个点只能走到编号在[1,min(n+m,1)][1,min(n+m,1)][1,min(n+m,1)]范围内的点.求路径长度恰好为kkk的简单路径(一个点最多走一次)数. 1≤n≤109,1≤m≤4,1≤k≤min(n,12)1\le n\le 10^9,1\le m\le 4,1\le k\le min(n,12)1≤n≤109,1≤m≤4,1≤k≤min(n,12) 分析 直接考虑走路径的话不能判有没有走过,然后就把路径转化为一个序列,每次往里面插入新的点(神了).因为…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
E - Qwerty78 Trip Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice Gym 100947E Description standard input/output Announcement   Statements Qwerty78 is a well known programmer (He is a member of the I…
C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is…
C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base…
CodeForces 140A New Year Table Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u  Description Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is…
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you fin…
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented a…
D - Chloe and pleasant prizes 链接 http://codeforces.com/contest/743/problem/D 题面 Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponso…
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct posit…