02 2016 档案

摘要:注意只有一个素因子的情况。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 5 using namespace std; 6 7 typedef long long ll; 8 const int INF = 0x3 阅读全文
posted @ 2016-02-29 23:08 Helica 阅读(239) 评论(0) 推荐(0) 编辑
摘要:打表输出前100之后,找到规律。 不过正确规律是1<<(二进制中1的个数)。 1 #include <cstdio> 2 #include <algorithm> 3 4 using namespace std; 5 6 7 int C[100][100]; 8 9 void pnt_bit(int 阅读全文
posted @ 2016-02-29 23:03 Helica 阅读(232) 评论(0) 推荐(0) 编辑
摘要:刚看到这个题的想法是建图搜路,写出来了才发现这个做法不行,不能把每一个矩形看成不可分的点,因为最终的矩形可能两条边出现在不同矩形里。 后来看了题解才明白直接暴力就行。关键是明白最终的矩形两条边都在所给矩形中出现。 1 #include <cstdio> 2 #include <algorithm> 阅读全文
posted @ 2016-02-29 22:57 Helica 阅读(299) 评论(0) 推荐(0) 编辑
摘要:模拟黄金矿工这个游戏,给出每一个金子的位置和所需时间,计算在给定时间内最大收益。 刚看这道题以为金子的位置没什么用,直接DP就行,WA了一发终于明白如果金子和人共线的话只能按顺序抓。 这就是需要考虑先后关系问题。看了背包⑨讲之后以为是“有依赖关系的背包”,感觉解决方案很不明显,想不出来做法。 后来想 阅读全文
posted @ 2016-02-29 22:51 Helica 阅读(311) 评论(0) 推荐(0) 编辑
摘要:记忆化数组记录从这个点的最长下降序列,然后乘以这个点的度,就是ans,维护即可。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1e5+10; const 阅读全文
posted @ 2016-02-22 13:30 Helica 阅读(215) 评论(0) 推荐(0) 编辑
摘要:水题 1 #include <cstdio> 2 #include <algorithm> 3 4 using namespace std; 5 6 int N,M,save[1000]; 7 8 int main() 9 { 10 scanf("%d%d",&N,&M); 11 for(int i 阅读全文
posted @ 2016-02-22 13:28 Helica 阅读(239) 评论(0) 推荐(0) 编辑
摘要:有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 阅读(212) 评论(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 阅读(252) 评论(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 阅读(253) 评论(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 阅读(447) 评论(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 阅读(288) 评论(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 阅读(211) 评论(0) 推荐(0) 编辑
摘要:有一个串,有黑色和白色两种元素。一次操作可以把最上面的白色元素变成黑色,同时把这个元素上面的所有元素变成白色。 给你一个30以内的串,计算变成全黑时,元素变化的总和。 我用的方法比较笨,打表处理了1-30个全白串变黑的ans,然后模拟,借助打表的结果计算出答案。 其实,每出现一个白色元素 cnt+= 阅读全文
posted @ 2016-02-21 16:42 Helica 阅读(237) 评论(0) 推荐(0) 编辑
摘要:从1-a和1-b种选两个数xy,计算出令gcd(x,y)=k的xy的对数。 对于每一个i∈[1,b]使用solve(i,n)函数解决有几个j∈[1,n]使gcd(x,y)=k。然后累加solve(i,n)-solve(i,i)即可,注意边界情况。 solve函数则使用容斥原理。 #include < 阅读全文
posted @ 2016-02-18 13:36 Helica 阅读(312) 评论(0) 推荐(0) 编辑
摘要:给出N个MAXN以内的不同的数,求出素因子最大的数。 使用朴素的方法分解素因子即可。时间复杂度为N*log(MAXN) 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 5 using namespace std; 6 阅读全文
posted @ 2016-02-18 13:21 Helica 阅读(282) 评论(0) 推荐(0) 编辑
摘要:找到规律模拟就可以了,用DFS模拟很简洁,用循环模拟比较直观(大概吧) 注意输入输出用%llu,1ULL<<64=0!被这几个小问题卡了好久 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; 阅读全文
posted @ 2016-02-17 23:25 Helica 阅读(270) 评论(0) 推荐(0) 编辑
摘要:依次考虑一个数的倍数,两个数的倍数(lcm),三个数的倍数(lcm)。。。 会发现有这么一个规律,奇数个数时要加上情况数,偶数个数时要减去情况数。 一种只有10个数,用二进制枚举所有情况即可。 #include <cstdio> #include <algorithm> #include <cstr 阅读全文
posted @ 2016-02-17 23:23 Helica 阅读(258) 评论(0) 推荐(0) 编辑
摘要:有n个家庭,m个房间,一个房间只能两个家庭住。求最大匹配。 比较标准的二分图问题。先初始化把可能的家庭建边,然后跑一边匈牙利算法。 最后的答案是最大匹配数/2,因为建图时有重复。 #include <cstdio> #include <algorithm> #include <cstring> #i 阅读全文
posted @ 2016-02-17 23:19 Helica 阅读(274) 评论(0) 推荐(0) 编辑
摘要:有两段字符串,第一段的尾和第二段的头可能重合。问有多少种组合的可能。 需要理解一下next数组的意义。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 10 阅读全文
posted @ 2016-02-17 23:15 Helica 阅读(170) 评论(0) 推荐(0) 编辑
摘要:很水的模拟题,拿数组搞就好了。 注意边界的地方不要算重。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int N,T,M; int save[10000]; char str[1000] 阅读全文
posted @ 2016-02-17 23:04 Helica 阅读(187) 评论(0) 推荐(0) 编辑
摘要:维护一个relation数组,保留着此元素和根元素之间的性别关系。之后就可以判断gay了。 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn=2010; int 阅读全文
posted @ 2016-02-02 00:07 Helica 阅读(193) 评论(0) 推荐(0) 编辑
摘要:记录元素个数的并查集。 利用sz数组保存并查集的大小。每次union时,把小的集合并到大的中去,并更新sz数组。 #include <cstdio> #include <algorithm> using namespace std; int n,m,k; int fa[30010],sz[30010 阅读全文
posted @ 2016-02-02 00:03 Helica 阅读(213) 评论(0) 推荐(0) 编辑
摘要:模板题 对于每修复一台终端,就遍历所有其他已修复的终端,如果距离在d之内,就union。 之后看是否在一个并查集中。 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int N,D,pos[ 阅读全文
posted @ 2016-02-02 00:01 Helica 阅读(164) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示