会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Driver_Lao
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
9
10
11
12
13
14
15
下一页
2017年12月6日
洛谷 1404 平均数
摘要: 【题解】 二分答案 在计算前缀和时减去mid,即s[i]=s[i-1]+a[i]-mid 这样只要有s[i]-s[j]>=0,且i-j>=m,那么mid就是符合条件的 用Min记录s[0]~s[i-m]中最小的s,即可做到O(n)判断 1 #include<cstdio> 2 #include<al
阅读全文
posted @ 2017-12-06 18:46 Driver_Lao
阅读(255)
评论(0)
推荐(0)
2017年12月4日
洛谷 1441 砝码秤重
摘要: 【题意概述】 现有n个砝码,重量分别为a1,a2,a3,……,an,在去掉m个砝码后,问最多能称量出多少不同的重量(不包括0)。 【题解】 先DFS决定用哪些砝码,然后DP求可以称出的重量有多少种 1 #include<cstdio> 2 #include<algorithm> 3 #include
阅读全文
posted @ 2017-12-04 21:42 Driver_Lao
阅读(229)
评论(0)
推荐(0)
【模板】高斯消元法
摘要: 洛谷1583 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 const int maxn=1000; 5 int n,x; 6 double a[maxn][maxn]; 7 inline void read(in
阅读全文
posted @ 2017-12-04 20:50 Driver_Lao
阅读(201)
评论(0)
推荐(0)
2017年12月1日
线段树练习题
摘要: 1.洛谷1531 点修改,查询区间最大值 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #define ls (cur<<1) 5 #define rs (cur<<1|1) 6 #define mid ((a[cur
阅读全文
posted @ 2017-12-01 19:31 Driver_Lao
阅读(205)
评论(0)
推荐(0)
2017年11月27日
【模板】非旋转Treap
摘要: Treap,也叫做树堆,是指有一个随机附加域满足堆的性质的二叉搜索树。 如果一棵二叉搜索树插入节点的顺序是随机的,那我们得到的二叉搜索树在大多数情况下是平衡的,期望高度是log(n). 但有些情况下我们并不能得知所有待插入节点,打乱以后再插入,这时我们需要给二叉搜索树加上一个随机附加域,并使这个随机
阅读全文
posted @ 2017-11-27 20:21 Driver_Lao
阅读(238)
评论(0)
推荐(0)
2017年11月9日
【模板】三分法
摘要: 洛谷3382 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 #include<cmath> 6 #include<algorithm> 7 using namespace std;
阅读全文
posted @ 2017-11-09 11:25 Driver_Lao
阅读(194)
评论(0)
推荐(0)
【模板】求1~n的整数的乘法逆元
摘要: 洛谷3811 先用n!p-2求出n!的乘法逆元 因为有(i-1)!-1=i!-1*i (mod p),于是我们可以O(n)求出i!-1 再用i!-1*(i-1)!=i-1 (mod p)即是答案 1 #include<iostream> 2 #include<cstring> 3 #include<
阅读全文
posted @ 2017-11-09 09:42 Driver_Lao
阅读(417)
评论(0)
推荐(0)
【模板】Hash
摘要: 洛谷3370 这题煞笔的吧QAQ......排序去重或者Map都可以 1 #include<cstdio> 2 #include<map> 3 #include<string> 4 using namespace std; 5 map<int, int> dic; 6 int ans=0,n; 7
阅读全文
posted @ 2017-11-09 08:49 Driver_Lao
阅读(116)
评论(0)
推荐(0)
【模板】最长公共子序列(二维偏序)
摘要: 给出1-n的两个排列P1和P2,求它们的最长公共子序列。 洛谷1439 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 const int maxn=100010; 5 int n,x,ans,tmp,pos[max
阅读全文
posted @ 2017-11-09 08:25 Driver_Lao
阅读(444)
评论(0)
推荐(0)
【模板】Tarjan缩点
摘要: 洛谷3387 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 const int maxn=20010,maxm=200010; 6 int ans,n,m,etot,tot,
阅读全文
posted @ 2017-11-09 08:02 Driver_Lao
阅读(131)
评论(0)
推荐(0)
2017年11月8日
【模板】RMQ问题 ST表
摘要: 洛谷3865 1 #include<cstdio> 2 #include<algorithm> 3 #include<cmath> 4 using namespace std; 5 const int maxn=100010; 6 int f[maxn][32],n,m,l,r; 7 void re
阅读全文
posted @ 2017-11-08 21:54 Driver_Lao
阅读(147)
评论(0)
推荐(0)
JSZXNOIP模拟赛 互测Round8T3 欢乐题(USACO)
该文被密码保护。
阅读全文
posted @ 2017-11-08 21:31 Driver_Lao
阅读(1)
评论(0)
推荐(0)
JSZXNOIP模拟赛 互测Round8 T2 瓜瓜的时空旅行
该文被密码保护。
阅读全文
posted @ 2017-11-08 18:16 Driver_Lao
阅读(2)
评论(0)
推荐(0)
2017年11月7日
【模板】树链剖分
摘要: 洛谷3384 1 #include<cstdio> 2 #include<algorithm> 3 #define ls (cur<<1) 4 #define rs (cur<<1|1) 5 #define len(x) (a[x].r-a[x].l+1) 6 #define mid ((a[cur
阅读全文
posted @ 2017-11-07 16:47 Driver_Lao
阅读(131)
评论(0)
推荐(0)
2017年11月6日
【模板】树链剖分求LCA
摘要: 洛谷3379 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 const int maxn=500010,inf=1e9; 5 int n,m,x,y,root,tot,dep[maxn],son[maxn],siz
阅读全文
posted @ 2017-11-06 19:43 Driver_Lao
阅读(145)
评论(0)
推荐(0)
【模板】KMP
摘要: 洛谷3375 讲解 1 #include<cstdio> 2 #include<cstring> 3 const int maxn=1000100; 4 int lp,lt,j,f[maxn]; 5 char p[maxn],t[maxn]; 6 7 void getfail() { 8 f[1]=
阅读全文
posted @ 2017-11-06 16:54 Driver_Lao
阅读(138)
评论(0)
推荐(0)
【模板】dijkstra
摘要: 洛谷 4779 手写堆的版本
阅读全文
posted @ 2017-11-06 15:48 Driver_Lao
阅读(208)
评论(0)
推荐(0)
2017年11月5日
BZOJ 1232 USACO 2008 Nov. 安慰奶牛Cheer
摘要: 【题解】 对于每一条边,我们通过它需要花费的代价是边权的两倍加上这条边两个端点的点权。 我们把每条边的边权设为上述的值,然后跑一边最小生成树,再把答案加上最小的点权就好了。 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std;
阅读全文
posted @ 2017-11-05 20:07 Driver_Lao
阅读(169)
评论(0)
推荐(0)
2017年11月3日
BZOJ 2054 疯狂的馒头
摘要: 【Description】 n个点,m次操作,每次把(i*p+q)%n+1与(i*q+p)%n+1之间的点染上颜色i,被染过色的会被新颜色覆盖,求最后每个点的颜色。 【题解】 因为被染过的颜色会被新的颜色覆盖,所以对于一个点,有效的染色只是最后一次。 那么我们可以倒着染色,已经染色的不染 求每个点被
阅读全文
posted @ 2017-11-03 20:21 Driver_Lao
阅读(191)
评论(0)
推荐(0)
BZOJ 4430 Guessing Camels赌骆驼
摘要: 【题意概述】 给出三个n的排列,求有多少个数对在三个排列中顺序相同 【题解】 考虑用补集转化的方法,答案为总对数-不满足的对数 一对数不满足条件,当且仅当这对数在两个排列中顺序相同,在另一个排列中的顺序不同。 统计两两之间不满足偏序条件的数对的个数,那么每对数都被统计了两次
阅读全文
posted @ 2017-11-03 19:06 Driver_Lao
阅读(224)
评论(0)
推荐(0)
上一页
1
···
9
10
11
12
13
14
15
下一页
公告