题目链接:http://codeforces.com/problemset/problem/1174/C 题意:给你一个n,要你填充 下标由2 ~ n 的数组ai,要求下标互质的俩个数不能相等,并且数组中最大值最小化. 思路:打个素数表,每个质数肯定互质所以我们令第一个质数为1,第二个质数为2...依次类推,然后根据 算术基本定理 ,合数就让它等于第一个分解的质数啦. AC代码: #include<bits/stdc++.h> using namespace std; ; int vis[MA…
链接: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…
做法 与\(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(){…
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…
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…
题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i<2^n$ 输出一个最长的这样的序列 数据范围: $1 \le n \le 18$$1 \le x<2^{18}$ 分析: 比赛的时候搞混$subsegment$和$subsequence$,前者为子段一定要连续,后者为子序列可以不连续 赛后看的官方题解 假设构造的序列为$a_i$,它的前缀异或和为$b_…
题目链接 边颓边写了半上午A掉啦233(本来就是被无数人过掉的好吗→_→) 首先可以\(Query\)一次得到\(a,b\)的大小关系(\(c=d=0\)). 然后发现我们是可以逐位比较出\(a,b\)在这每位上的大小关系的. 最后还剩下\(a,b\)相等的位需要再判断是\(0\)还是\(1\),\(a,b\)分别异或一个\(1,0\)就可以了(假如都是\(0,0\),那异或之后\(1,0\)是\(a>b\):如果都是\(1,1\),异或之后就是\(0,1\),\(a<b\)). 询问次数\(…
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…
E. Ehab's REAL Number Theory Problem 数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:\(1<=a_i<=10^6\) \(a_i\) 最多只有7个因数 题目要求在这个数列找到一个最短的子数列,子数列的所有的数相乘是一个完全平方数. 题解: 这个题对于 \(x^{3}\) 应该等价于 \(x\) ,其实就是可以除去 \(a_i\)中的所有的平方项,显而易见,这个并不影响答案. 因为 \(a_i\) 最多只…