这个题好像可以直接暴力过.我是先用num[len]统计所有每个长度的数量有多少,假如在长度为len下,如果要考虑旋转后和原来图案保持一致,我们用a表示在一个旋转单位中有几个长度为len的线段,b表示有几个这样的旋转单位,那么可以表示a*b=num[len],满足这样的a,b一定可以满足要求,这时候就可以发现只需要枚举因子暴力扫过去即可,我们用map存下所有点的位置,在枚举块的数量时是直接可以算出旋转角,那我们直接对所有点进行判断,旋转后是否存在这样的一个点.有一个坑,当num[len]长度为1时…
Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circumference is equally divided by nn points numbered clockwise from 11 to nn, such that points ii and i+1i+1 (1≤i<n1≤i<n) are adjacent, and so are poin…
P1414 又是毕业季II:https://www.luogu.org/problemnew/show/P1414 题意: 给定一个长度为n的数列.要求输出n个数字,每个数字代表从给定数列中最合理地取出 i 个数后的最大公约数. 思路: 枚举因子,复杂度为n*(sqrt(max)),若一个因子x出现了k次,那么说明从数列中取出 k 个数至少可以得到最大公约数x. * 1. 求出每个因数出现的次数. * 2. 对于每个次数记录最大的因数. * 3. 根据f[k]=max(f[k],f[k+1])逆…
codeforces 895A Pizza Separation 题目大意: 分成两大部分,使得这两部分的差值最小(注意是圆形,首尾相连) 思路: 分割出来的部分是连续的,开二倍枚举. 注意不要看成01背包,一定多读题 代码: #include <bits/stdc++.h> using namespace std; int a[800]; int main() { int n,minval,sum,tot; cin>>n; tot=0; for(int i=1;i<=n;+…
C. Ilya And The Tree 题意 给一棵树求每个点到根的路上允许修改一个为0,gcd的最大值. 题解 g是从根到当前点允许修改的最大gcd,gs为不修改的最大gcd.枚举当前点的因子,更新路径上每个因子出现次数,回溯时减去.并用这个因子更新答案.另外当前点修改为0时,还要用父节点的gs更新答案.复杂度\(O(n\sqrt n)\) 代码 const int N=201000; int n; int a[N]; int u,v; VI e[N]; int g[N],gs[N]; in…
https://codeforces.com/contest/1132/problem/C 枚举 + 差分前缀和 题意 有一段[1,n]的线段,有q个区间,选择其中q-2个区间,使得覆盖线段上的点最多为多少? 题解 一开始用贪心搞,搞到一半发现需要枚举的情况太多 只能用暴力搞,即枚举被去掉的两个区间,那么如何判断去掉哪两个区间比较好? 维护去掉后剩下的点数即答案 代码 #include<bits/stdc++.h> using namespace std; int n,q,i,j,l[5005…
Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n. Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom…
题意:      给一个n(<=10Y),然后让找到一个最小的m使得n/m是一个素数. 思路:       先用sqrt(n)的时间把所有的因子都求出来,然后在排序,枚举,就行了,这个题目这么做的话,要是仔细算一下时间复杂度估计会跪,但是题目说大数据不多,这种说法的前提下一般临街的时间复杂度都要试一试,还有就是在判断素数和枚举的时候写的别太挫,不然很可能会超时. #include<algorithm> #include<stdio.h> #include<math.h&…
题意: 有两个点喷水,有很多个点有花,给出坐标. 求使得每个花都可以被喷到,两个喷水的半径的平方的和最小是多少. 思路: 枚举其中一个喷水的最大半径. 坑: 这题我贪心的思路有很大问题.一开始也是想这样枚举的,但是思路超级混乱,按照r2进行贪心但是最后想想想法很荒谬. 顺序和题意一定要搞的很透彻才可以== #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struc…
题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was…