2014年11月4日

Hdu5087Revenge of LIS II简单dp

摘要: 有个坑点,就是转移的时候前面状态数量如果不同,后面即使从同一个点转移过来,也是不同的。#include#include#include#include#include#includeusing namespace std;typedef long long LL;const LL maxn = 11... 阅读全文

posted @ 2014-11-04 08:19 一个西瓜 阅读(138) 评论(0) 推荐(0)

Hdu5088Revenge of Nim II高斯消元

摘要: 比赛的时候不会写,但是网上有基本一样的题。出题水了。。这题把每个数拆成2进制,然后就和开关灯一样了。然后学了下高斯消元kuangbin大神的高斯消元模板。http://www.cnblogs.com/kuangbin/archive/2012/09/01/2667044.html#include#i... 阅读全文

posted @ 2014-11-04 08:17 一个西瓜 阅读(156) 评论(0) 推荐(0)

Poj1830开关问题,高斯消元

摘要: 高斯消元的入门题。#include#include#include#include#include#includeusing namespace std;int Map[100][100];int gauss(int equ, int var){ int k; int col; for ... 阅读全文

posted @ 2014-11-04 08:13 一个西瓜 阅读(166) 评论(0) 推荐(0)

Poj3370Halloween treats鸽巢原理

摘要: 和上题差不多一样的搞法。#include#include#include#include#include#includeusing namespace std;const int maxn = 111111;int a[maxn]; int b[maxn];int vis[maxn];int mai... 阅读全文

posted @ 2014-11-04 08:11 一个西瓜 阅读(125) 评论(0) 推荐(0)

Poj2356Find a multiple鸽巢原理

摘要: 一定存在连续的k个数,使得他们的和能被n整除。设a[i]为前缀和a[1]%n ,a[2]%n,...,a[n]%n的值的范围#include#include#include#include#includeusing namespace std;typedef long long LL;int m... 阅读全文

posted @ 2014-11-04 08:10 一个西瓜 阅读(130) 评论(0) 推荐(0)

Poj3145Harmony Forever线段树+鸽巢原理

摘要: 小数据直接暴力,大数据查找0-mod — 1,mod — 2*mod-1,2*mod — 3*mod-1.....因为 n%mod 的范围#include#include#include#include#includeusing namespace std;typedef long long L... 阅读全文

posted @ 2014-11-04 08:05 一个西瓜 阅读(199) 评论(0) 推荐(0)

hiho16动态lca

摘要: 这个要好写点,就是dfs这棵树,将每个节点进入 和出去的位置都记录下来,然后找 所要求得两个点最后出现的位置之间的最小值 所对应的点,就是他们的最近公共祖先。#include#include#include#include#includeusing namespace std;const int m... 阅读全文

posted @ 2014-11-04 07:53 一个西瓜 阅读(360) 评论(0) 推荐(0)

hiho15周离线lca

摘要: 它上面讲的很详细。http://hihocoder.com/problemset/problem/1067?sid=210395#include#include#include#include#includeusing namespace std;const int maxn = 111111;in... 阅读全文

posted @ 2014-11-04 07:50 一个西瓜 阅读(182) 评论(0) 推荐(0)

hiho13周暴力求lca

摘要: 先求一个节点的所有先人,然后从另外一个节点开始向上找,找到第一个共同的先人就是最近公共祖先。#include#include#include#includeusing namespace std;int fathe[1222];int color[122];int father[1222];int ... 阅读全文

posted @ 2014-11-04 07:49 一个西瓜 阅读(212) 评论(0) 推荐(0)

hiho12周树形dp

摘要: #include#include#includeusing namespace std;const int maxn = 1111;int len;int head[maxn];//int father[maxn];struct Node{ int to; int next;}e[maxn *... 阅读全文

posted @ 2014-11-04 07:47 一个西瓜 阅读(177) 评论(0) 推荐(0)

hiho11周树的直径

摘要: 任意找一个点做根, 然后找到距离这个根最远的点,然后以这个点做根,再找距离这个根最远的点,两个距离和就是 树的直径。#include#include#include#include#include#includeusing namespace std;typedef long long LL;#de... 阅读全文

posted @ 2014-11-04 07:45 一个西瓜 阅读(180) 评论(0) 推荐(0)

导航