随笔分类 - 算法
摘要:先以x排序,然后求小区间的最小距离M,然后合并到大区间,把距离小于M的点加入新集合,对新集合以Y排序,更新最小值 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std
阅读全文
摘要:题目:https://vjudge.net/contest/364745#problem/B 先用三分求出最高点Y,然后在进行二分,求出角度 注意写法 PI的弧度是 acos(-1)/2-EPS接近90度的时候相当于除以0二分的精度可以用迭代次数来保证,比如100次 #include <iostre
阅读全文
摘要:以后写l和r的初始值的时候,在不影响合理性的前提下,尽量写大一点 比如下面这个代码,如果r不加以或者l==0就不行 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmat
阅读全文
摘要:假二分,并不是钱越多,买的书就越多。 比如你有14块和12块 13 2 3 4 14块买一本,12块买三本 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #
阅读全文
摘要:https://www.cnblogs.com/perseawe/archive/2012/05/03/01fsgh.html 参考这个博客 #include <set> #include <map> #include <queue> #include <math.h> #include <vect
阅读全文
摘要:参考的事这个博客 #include <set> #include <map> #include <queue> #include <math.h> #include <vector> #include <string> #include <stdio.h> #include <string.h> #
阅读全文
摘要:这个题不难,就是想记录一下这个更新的方式,很漂亮! #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> #include <m
阅读全文
摘要:传送门:https://vjudge.net/contest/363330#problem/A 题意,nxn的矩阵,每列都是递增的,求整个矩阵中从小到大第m个的数是什么 易错点: 算法中二分找的是一个数x,比它小的数有m个,这样x减一就等等于第m个的数了。 如果直接二分找一个结果res,比res小的
阅读全文
摘要:题解:使用二分搜索,在输出小数问题上,一般都会指定允许的误差范围或者是输出中小数点后面的位数。因此在使用二分搜索法时,有必要设置合理的结束条件来满足精度的要求。 设定循环次数作为终止条件,1次循环可以把区间的范围缩小一半,100次的循环则可以达到10^(-30)的精度范围,基本上是没有问题的,也可以
阅读全文
摘要:巧妙地预处理 + 扫描线 https://blog.csdn.net/weixin_41380961/article/details/90083696 别人的代码,平台有问题,我没写 https://vjudge.net/problem/UVALive-3905 #include<stdio.h>
阅读全文
摘要:结构体+优先队列+贪心 #include <iostream> #include <cstdio> #include <cstring> #include <limits> //#include <stack> #include<queue> #include <algorithm> #define
阅读全文
摘要:贪心,有一些点少不留意就会wa #include <iostream> #include <cstdio> #include <cstring> #include <limits> //#include <stack> #include<queue> #include <algorithm> #de
阅读全文
摘要:贪心+预处理 有个点 就是写错了,找了半天哇。 R是double类型不是int类型! #include <iostream> #include <cstdio> #include <cstring> #include <limits> #include<cmath> #include <algori
阅读全文
摘要:并查集+贪心 https://vjudge.net/contest/362147#problem/C #include <iostream> #include <cstdio> #include <cstring> #include <limits> #include <algorithm> #de
阅读全文
摘要:#include <cstdio> #include <iostream> #include <cmath> #include <cstdlib> #include <cstring> #define _for(i,a,b) for(int i= a;i<b;i++) using namespace
阅读全文
摘要:并查集 #include<iostream> #include<string.h> #include<algorithm> #include<cmath> #include<map> #include<string> #include<stdio.h> #include<vector> #inclu
阅读全文
摘要:注意set的交集和并集的写法 #include<bits/stdc++.h> using namespace std; map< set<int>,int > Map; vector< set<int> > Setcache; stack<int> sta; int ID( set<int> x)
阅读全文
摘要:带标记的并查集 ,原来加速后也不见得就很快了 #include<cstdio> #include<iostream> #define endl '\n' #define _for(i,a,b) for(int i=a;i<b;i++) using namespace std; const int N
阅读全文
摘要:https://vjudge.net/contest/360957#problem/F 题解 https://blog.csdn.net/niushuai666/article/details/6981689 #include<iostream> #include<cstdio> #include<
阅读全文
摘要:https://vjudge.net/contest/360957#problem/E m行n列的一个矩阵 求:每行选一个数,求前n个最小的sum是多少。 思路用优先队列维护前i行的结果,再根据这个遍历求出前i+1行的,以此类推。 #include <iostream> #include <cstd
阅读全文

浙公网安备 33010602011771号