![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数学
paranoidZ
这个作者很懒,什么都没留下…
展开
-
区间合并
思路:左端点从小到大进行排序,遍历合并区间,主要有俩种大情况,1.当前区间左端点大于上一个区间的右端点,此时说明上一个区间已经合并完成了,2.当前左端点小于或者等于上一个区间的右端点,则保持左端点不动,右端点取一个最大值即可 code: #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #define INF 0x3f using n...原创 2021-02-08 16:58:19 · 156 阅读 · 0 评论 -
位运算
求n的第k位数字: n >> k &1 求n的二进制中的最后一个1表示的数字: lowbit (x) =x & -x; 题目:二进制中1的个数 code: //二进制补码表示负整数 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int lowbit(int x){//返回最后一个1表示的数...原创 2021-02-08 15:58:31 · 111 阅读 · 0 评论 -
双指针算法
双指针算法的核心思想: 这个就不是那种直接暴力,而是i和 j指针遍历俩遍数组 ,所以是O(2 * n)的 题目:最长连续不重复子序列 code: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N = 100010; int a[N]; int s[N];//记录每一个数出现的次数 int main() { ...原创 2021-02-06 22:41:49 · 69 阅读 · 0 评论 -
二维前缀和与差分
二维前缀和: 原理:矩阵的前缀和存在一个地推关系,如下图所示 解决的问题:子矩阵中所有数的和 公式:a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1]; code; #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N = 1100; in...原创 2021-02-06 15:26:45 · 313 阅读 · 0 评论 -
AtCoder Regular Contest 111
题目连接:https://atcoder.jp/contests/arc111/tasks/arc111_a A - Simple Math 2 这个是官方的题解 思路:和 是等价的先关的证明如上所示 。这就相当于对 M^2取余 code: #include<iostream> #include<algorithm> #include<cstdio> using namespace std; typedef ...原创 2021-01-10 12:26:25 · 390 阅读 · 1 评论 -
Codeforces Round #657 (Div. 2)B:Dubious Cyrpto
题目连接: 题意:求 a b c 存在一个正整数n使m=n*a+b-c; 题面给出m和a b c的范围[l,r] 思路: 原方程可以化为 n*a=m+c-b n*a∈[m+l-r,m+r-l] , 枚举a 的所有值,求每个a对应n的最大值n=m+r-l/a 然后n*a-m的范围应该是[l-r,r-l]且n>0 求出n和a后注意讨论一下c-b的正负情况 。 c-b正:取b=l c=b+n*a-m c-b负:取c=l,b=c+m-n*a code: #include<io...原创 2020-07-20 19:15:39 · 119 阅读 · 0 评论 -
C. Celex Update
题目连接:https://codeforces.com/contest/1358/problem/C output standard output During the quarantine, Sicromoft has more free time to create the new functions in "Celex-2021". The developers made a new functionGAZ-GIZ, which infinitely fills an infinite tab.原创 2020-05-27 11:02:12 · 283 阅读 · 0 评论 -
AtCoder Beginner Contest 168 C:(Colon)
题目连接:https://atcoder.jp/contests/abc168/tasks/abc168_c C - : (Colon) Time Limit: 2 sec / Memory Limit: 1024 MB Score:300300points Problem Statement Consider an analog clock whose hour and minute hands areAAandBBcentimeters long, respectively...原创 2020-05-18 16:19:12 · 234 阅读 · 0 评论