做法 与\(x\)互质的数填不同的数,把有向关系表示出来,发现边数是不能承受的 反过来想,成倍数关系填相同的数,把这些数想象成一条链,而这条链开始的数一定是质数,\(\sum\limits_{prime_i}\frac{n}{prime_i}\)是可以承受的 把这条链的点赋一个相同的值 Code #include<bits/stdc++.h> using namespace std; typedef int LL; const LL maxn=1e6+9; inline LL Read(){…
链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer ii from 22 to nn, assign a positive integer aiai such that the following conditions hold: For any pair of integers (i,j)(i,j), if ii and jj are coprime…
题目链接:http://codeforces.com/problemset/problem/1174/C 题意:给你一个n,要你填充 下标由2 ~ n 的数组ai,要求下标互质的俩个数不能相等,并且数组中最大值最小化. 思路:打个素数表,每个质数肯定互质所以我们令第一个质数为1,第二个质数为2...依次类推,然后根据 算术基本定理 ,合数就让它等于第一个分解的质数啦. AC代码: #include<bits/stdc++.h> using namespace std; ; int vis[MA…
You're given an integer nn. For every integer ii from 22 to nn, assign a positive integer aiai such that the following conditions hold: For any pair of integers (i,j)(i,j), if ii and jj are coprime, ai≠ajai≠aj. The maximal value of all aiai should be…
E. Ehab's REAL Number Theory Problem 数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:\(1<=a_i<=10^6\) \(a_i\) 最多只有7个因数 题目要求在这个数列找到一个最短的子数列,子数列的所有的数相乘是一个完全平方数. 题解: 这个题对于 \(x^{3}\) 应该等价于 \(x\) ,其实就是可以除去 \(a_i\)中的所有的平方项,显而易见,这个并不影响答案. 因为 \(a_i\) 最多只…
Ehab and a component choosing problem 如果有多个连接件那么这几个连接件一定是一样大的, 所以我们先找到值最大的连通块这个肯定是分数的答案. dp[ i ]表示对于 i 这棵子树包含 i 这个点的连通块的最大值, 就能求出答案, 然后知道最大值之后再就能求出几个连接件. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make…
E. Ehab and a component choosing problem 题目链接:https://codeforces.com/contest/1088/problem/E 题意: 给出一个数,找出k个连通块,使得连通块里面点的和除以k最大.当选择不同数量的连通块有相同的最大值时,要求输出k最大的情况. 题解: 由于这个不等式average(x1,x2,x3...xn)<=max(x1,x2,...xn)成立(当且仅当x1=x2=...xn时,等号成立),而题目所求正好是连通块里面点和…
D. Ehab and another another xor problem 题目链接:https://codeforces.com/contest/1088/problem/D Description: This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b)(a,b). Laggy can ask a pair of integers (c,d)(c,d) a…
Ehab's REAL Number Theory Problem 前置知识 质数 分解质因数 无向无权图最小环<讲> Ehab's REAL Number Theory Problem/onCF 给 \(n\) 个数 \(a_i\)(\(a_i\) 的因数个数不超过 \(7\)),求最少选出多少个数,使得乘积为完全平方.无解输出 \(-1\). 数据范围:\(1\le n\le 10^5\),\(1\le a_i\le 10^6\). 没想到一场普通的 \(\texttt{CF}\) 比赛能…
题目大意:对于一个序列,定义它的价值是它的所有前缀的 $\gcd$ 中互不相同的数的个数.给定整数 $n$,问在 $1$ 到 $n$ 的排列中,有多少个排列的价值达到最大值.答案对 $10^9+7$ 取模. $2\le n\le 10^6$. 一道 Div. 2 的难度 2500 的题,真的不是吹的…… 首先考虑排列的第一个数 .假如分解质因子后为 $\prod p_i^{c_i}$,那么此时排列价值的最大值为 $\sum c_i$. 为什么?因为如果 $\gcd$ 变了,那么一定变成原来 $\…