摘要: 有m盘菜,每盘有一个开始时间和结束时间,必须每盘都吃同样的时间。问最多能吃多久。 二分答案,然后用一个优先队列维护当前时间内的菜,然后每次都吃结束时间最小的那盘。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #i 阅读全文
posted @ 2016-02-21 23:18 Helica 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 一共左右两排共2N盏灯,计算每排都亮M盏以上的期望。每天每盏灯有P的概率点亮。 dp[i][j]记录左边i盏右边j盏时的期望,从dp[N][N]往前推。//没学概率论写的好懵逼。 1 #include <cstdio> 2 #include <cstring> 3 #include <iostrea 阅读全文
posted @ 2016-02-21 23:14 Helica 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstring> 2 #include <algorithm> 3 #include <iostream> 4 #include <queue> 5 6 using namespace std; 7 8 typedef long long LL; 9 const int ma 阅读全文
posted @ 2016-02-21 17:08 Helica 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 用dp求出最大的表达,再用dp求出。//然而并没有想出来 1 #include <cstdio> 2 #include <string> 3 #include <algorithm> 4 #include <iostream> 5 6 using namespace std; 7 8 const i 阅读全文
posted @ 2016-02-21 17:05 Helica 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 裸网络流题。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <queue> 5 using namespace std; 6 7 const int maxn = 1200; 8 const in 阅读全文
posted @ 2016-02-21 16:59 Helica 阅读(446) 评论(0) 推荐(0) 编辑
摘要: 经过研究可以发现,每一位的贡献是C(n-2,k-1)+C(n-3,k-1)...C(k-1,k-1) 同时还要注意加号全部在左边的情况。 这里还用了O(n)预处理O(1)组合数的模板。//妙啊。。妙。。。 1 #include <cstdio> 2 #include <cstring> 3 #inc 阅读全文
posted @ 2016-02-21 16:55 Helica 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 树上每个元素有一个p,元素之间有距离d,计算一个元素u,使得sigma(d(i,u)*pi)最小。 两次dfs,第一次计算本节点以下的sigma(),第二次利用sump求解出ans。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cst 阅读全文
posted @ 2016-02-21 16:47 Helica 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 有一个串,有黑色和白色两种元素。一次操作可以把最上面的白色元素变成黑色,同时把这个元素上面的所有元素变成白色。 给你一个30以内的串,计算变成全黑时,元素变化的总和。 我用的方法比较笨,打表处理了1-30个全白串变黑的ans,然后模拟,借助打表的结果计算出答案。 其实,每出现一个白色元素 cnt+= 阅读全文
posted @ 2016-02-21 16:42 Helica 阅读(233) 评论(0) 推荐(0) 编辑