A. Square Function 留坑. B. Guess by Remainder 询问$lcm(1,2,3,...,n)-1$即可一步猜出数. 计算$lcm$采用分治FFT即可,时间复杂度$O(n\log^2n)$. C. Subtract if Greater! 对于每个修改操作,$[1,x]$的数无需修改,$[x+1,2x]$的数会减小至少一半,暴力修改即可,$[2x+1,inf]$的数减小之后排名不变,故可以在平衡树上打标记实现. 时间复杂度$O(n\log^2n+m\log n)…
2016 Sichuan Province Programming Contest 代码 2016 Sichuan Province Programming Contest A. Nearest Neighbor Search \(dx\)根据\(x_0\)与\([x_1, x_2]\)位置考虑. \(dx.dy.dz\)单独考虑. B. Odd Discount 做法一:对于两个不同优惠\((i,j)\),所有方案中与两个优惠商品交集为奇数,即同时取到两种优惠的个数为\(2^{n-2}\)种.…
2016 Hunan Province Programming Contest A. 2016 题意 \(1 \le a \le n, 1 \le b \le m\) ,其中\(1 \le n,m \le 10^9\) 求正整数\((a,b)\)对的数量,满足\(ab \% 2016 = 0\) 思路 \(2016=2^53^27\) 根据\(a\)对因子的贡献对\(a\)分类,每种方案数对应\(b\)的数量,即\[\lfloor \frac{m}{\frac{2016}{a}} \rfloor…
2016 China Collegiate Programming Contest Final Table of Contents 2016 China Collegiate Programming Contest FinalProblem A:Problem J:Problem H: Problem A: 题意:喝咖啡,每三杯就又可以有免费一杯,求最少花费: 分析:贪心: #include <bits/stdc++.h> using namespace std; const int inf…
2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic 题意:有一张图,第i个点被占领需要ai个兵,而每个兵传送至该点需要bi的费用.占领第i条边需要其两端点的兵数之和大等于ci.对于已占领的点或边可以免费通行.因此兵达到一个点的手段有传送和沿路走.图上的兵可以在已占领的点.边随意调度. 求占领所有点的最小花费. 思路:将边按ci进行升序排列,对于每条边两端点所在的连通块进行合并,合并细节见代码.这里有一点值得思…
题目列表 A.ABBA E.Elvis Presley G. Biological Software Utilities J. Burnished Security Updates A.ABBA 题意:就是问你一个矩阵能由几个行向量表示出来 Solution 其实就是求矩阵的秩,但是会被卡精度(被卡了好几发),直接抄个矩阵求秩的板子就AC了 Code #define CLR(x) memset(x,0,sizeof(x))//定义宏 using namespace std; double mat…
链接:http://codeforces.com/gym/101116 学弟写的,以后再补 #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <map> #include <vector> using namespace std; map<string,int>v,ans; vector<in…
链接:http://codeforces.com/gym/101116 题意:给出n个点,要求一个矩形框将(n/2)+1个点框住,要面积最小 解法:先根据x轴选出i->j之间的点,中间的点(包括两边)按照y排序,固定一边X=(xj-xi),Y就枚举点两端的Y坐标,细节是注意要取(n/2)+1个点 事实上这样取里面一定符合要求 #include <iostream> #include <cstdio> #include <algorithm> #include &l…
链接:http://codeforces.com/gym/101116 题意:选六个数,必须出现次数最多,且数字最小,如果出现7优先加入7 解法:排序,出现7优先加入7,最后再将6个数排序 #include<bits/stdc++.h> using namespace std; struct P { int num,pos,M; }He[1000]; bool cmd(P a,P b) { if(a.pos==b.pos) { return a.M<b.M; } else { retur…
链接:http://codeforces.com/gym/101116 学弟做的,以后再补 #include <iostream> #include <stdio.h> #include <cstring> #include <string> using namespace std; int a[505]; int main(){ int T; cin>>T; string s[505]; while(T--){ memset(a,0,sizeo…