上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: 已知某矩阵中的值已经确定,需求矩阵中某个小矩阵的最值 ST算法 我们可以将每一行看作一维的rmq maxx[i][j][k]表示: 第i行 [j,j+(1<<k)-1] 区间中的最大值 maxx[i][j][k]=max(maxx[i][j][k-1],maxx[i][j+(1<<(k-1))][k 阅读全文
posted @ 2018-01-31 16:20 jadelemon 阅读(359) 评论(0) 推荐(0) 编辑
摘要: ST算法: 为离线算法,查询最值问题 minn[i][j]表示区间 [i , i+(1<<j)-1] 的最小值,minn[i][j]一定是偶数个数的最小值,所以对它一分为二 状态方程:minn[i][j]=min(minn[i][j-1],minn[i+(1<<(j-1))][j-1]) 查询[l, 阅读全文
posted @ 2018-01-29 20:03 jadelemon 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 矩阵快速幂讲解 若求斐波那契数列第n项的数值,我们可以递推求得,若n值(>1e10)很大,我们一个一个求,一定会超时,下面讲解一下用矩阵快速幂求解 矩阵快速幂就是:求矩阵A^n的矩阵,如同快速幂一样,代码极其相似,将快速幂中的整数乘法改为矩阵的乘法即可 矩阵乘法: 其中c[i][j]为矩阵A的第i行 阅读全文
posted @ 2018-01-29 18:57 jadelemon 阅读(757) 评论(2) 推荐(1) 编辑
摘要: Mishka and Interesting sum 题意:查询区间中出现偶数次的数的异或和 树状数组 若是求奇数次的数的异或和,很好求区间[l,r]的异或和,即前r项异或和与前l-1项异或和异或即可 但这要求偶数次的,想办法把偶数的转化成奇数的,即区间中出现奇数次的异或和与不同数的异或和 异或 即 阅读全文
posted @ 2018-01-25 20:57 jadelemon 阅读(188) 评论(0) 推荐(0) 编辑
摘要: U - How Many Calls? UVA - 10518 题意: 询问斐波那契数f(n)调用几次,我们可以写出方程:F(n)=F(n-1)+F(n-2)+1 代码如下: #include <iostream> #include <cstdio> #include <cmath> #includ 阅读全文
posted @ 2018-01-23 10:12 jadelemon 阅读(210) 评论(0) 推荐(0) 编辑
摘要: So Easy! http://acm.hdu.edu.cn/showproblem.php?pid=4565 代码如下: #include<stdio.h> #include<cstring> #define N 2 #define LL long long int m=2; LL MOD; st 阅读全文
posted @ 2018-01-15 20:42 jadelemon 阅读(329) 评论(0) 推荐(0) 编辑
摘要: In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the quest 阅读全文
posted @ 2018-01-12 21:32 jadelemon 阅读(360) 评论(0) 推荐(0) 编辑
摘要: Codeforces Round #226 (Div. 2) E. Bear in the Field time limit per test 1 second memory limit per test 256 megabyte Our bear's forest has a checkered 阅读全文
posted @ 2018-01-12 16:59 jadelemon 阅读(252) 评论(0) 推荐(0) 编辑
摘要: A. Visiting a Friend 水题,但是需要注意段点初,及最后的位置 代码如下: B. Coloring a Tree 额。。。也挺水的,dfs或bfs即可,起点任意一点即可 代码如下: C. Hashing Trees 找到规律,发现当a[i]>1&&a[i-1]>1是该树会出现异构, 阅读全文
posted @ 2017-12-20 23:33 jadelemon 阅读(146) 评论(0) 推荐(0) 编辑
摘要: A. Splitting in Teams 水题贪心,数列有1,2两种元素,求组成3的最大方案,首先找到1的个数a,2的个数b,尽可能满足2,若b>=a,则就输出a,否则,输出b+(a-b)/3 代码如下: B. Months and Years 暴力,特别注意:相邻两年不可能都是润年,因为数据量很 阅读全文
posted @ 2017-12-17 20:58 jadelemon 阅读(250) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页