自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

嗯。

嗯。

  • 博客(39)
  • 资源 (2)
  • 收藏
  • 关注

转载 2-SAT题集

【HDU】3062 Party1824 Let's go home3622 Bomb Game3715 Go Deeper1815 Building roads1816 Get Luffy Out *1814 Peaceful Commission4115 Eliminate the Conflict4421 Bit Magic===========

2014-05-30 23:11:05 1330

原创 POJ 1038 Bugs Integrated, Inc. 状态压缩DP

题目来源:1038 Bugs Integrated, Inc.题意:最多能放多少个2*3的矩形思路:状态压缩DP啊 初学 看着大牛的代码搞下来的  总算搞懂了 接下来会更轻松吧3进制代表前2行的状态(i行和i-1行)1代表i-1行占位 2代表i行占位 i-1不管有没有占位都不会影响的0代表i行和i-1行都空闲然后枚举状态dfs更新状态 话说就不能没写深搜了 有点不会了#incl

2014-05-30 21:29:04 1459

原创 HDU 3367 Pseudoforest 最大生成树

题目来源:HDU 3367 Pseudoforest题意:每个连通块最多可以有一个环 求最大的森林思路:考虑最大生成树 如果祖先一样没有环 那就合并 如果祖先不一样 如果2棵树都没有环 合并 如果有1棵树有环 合并 标记该棵树有环#include #include #include using namespace std;const int maxn = 100010;str

2014-05-29 10:24:33 1071

转载 矩阵连乘题集

你能全都做完,你的矩阵就小成了,1.hdu 1005 矩阵基础题 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005题解代码链接:http://blog.csdn.net/a601025382s/article/details/102514232.hdu 1575 矩阵基础题题目链接:http:

2014-05-28 13:02:27 989

原创 矩阵模版

矩阵快速幂const int maxn = 3;struct Mat{ int a[maxn][maxn];};Mat A, B, C, D;int n, m;Mat get(Mat x, Mat y){ Mat z; memset(z.a, 0, sizeof(z.a)); for(int i = 1; i <= 2; i++)

2014-05-28 11:36:33 838

原创 Light OJ 1258 Making Huge Palindromes 末尾添加最少字符变回文串

题目来源:Light OJ 1258 Making Huge Palindromes题意:末尾添加最少的字符是使输入的串变成回文 输出长度思路:直接KMP匹配出它和它反串的最大匹配 n减去它就是要添加的数量#include #include #include using namespace std;const int maxn = 1000010;char a[maxn],

2014-05-27 17:53:12 1087

原创 Light OJ 1102 Problem Makes Problem 组合数

题目来源:Light OJ 1102 Problem Makes Problem题意:一个整数n分解成k个数相加有多少种方案 数字可以重复 思路:m个苹果放n个盒子有多少方案 允许盒子有空 盒子空对应0 答案是C(n+m-1, n-1) 首先如果不允许有空 答案是C(m-1, n) 插空法m个苹果有m-1个空档 在这m-1个空档里选n-1个分成了n部分 每部分都不是空的现在允许为空

2014-05-27 16:50:30 974

原创 POJ 2155 Matrix 二维树状数组

题目来源:POJ 2155 Matrix题意:开始矩阵都是0 2种操作 把某个子矩阵翻转 0变1 1变0 查询x y 是0还是1思路:树状数组 记录翻转次数就行 奇数次是1 偶数次是0 这题是区间更新 点查询   向上求和 向下更新 而且是二维的#include #include using namespace std;const int maxn = 1300;i

2014-05-26 18:00:07 1052

原创 POJ 1990 MooFest 树状数组

题目来源:POJ 1990 MooFest题意:就算每两头牛之间声音值 2头牛v的最大值*2头牛之间的距离思路:按照v从小到大插入树状数组 每插入一头牛i 统计x比他小的个数s1 x比他大的个数s2 x比他小的距离l1 x比他大的距离l2 求和#include #include #include using namespace std;const int maxn = 2001

2014-05-26 14:28:19 943

原创 POJ 2019 Cornfields 二维RMQ

题目来源:POJ 2019 Cornfields题意:求正方形二维区间最大最小值的差思路:直接二维ST搞 试模版而已#include #include #include using namespace std;const int maxn = 255;int dp[maxn][maxn][8][8];int dp2[maxn][maxn][8][8];int a[

2014-05-24 23:48:13 1026

原创 RMQ模版

STint dp[maxn][20];int a[maxn];void RMQ_init(int n){ int i,j,k; for(i = 1; i <= n; i++) dp[i][0] = a[i]; k = (int) (log((double)n + 0.2) / log(2.0)); for(j = 1; j <= k; j++) for(i =

2014-05-24 19:25:06 853

原创 Light OJ 1234 Harmonic Number 调和级数部分和

题目来源:Light OJ 1234  Harmonic Number题意:思路:没思路啊 这个是高数的东西 发散 n足够大时它无穷大 直接公式解#include #include #include #include #include #include using namespace std;const int maxn = 1000010;const doub

2014-05-24 16:25:29 1209

原创 POJ 3164 Command Network 最小树形图-朱刘算法裸题

题目来源:POJ 3164 Command Network题意:求以1为根的最小树形图 没有输出字符串思路:直接高朱刘算法 不懂的可以百度 学会了就是直接套模板的事情 其实就是不断消圈而已 不构成圈就有解 无法从根到达其他点就无解 #include #include #include const int maxn = 110;const int maxm = 500

2014-05-23 20:58:20 1071

原创 UVa 10294 Arif in Dhaka (First Love Part 2) Polya定理

题目来源:UVa 10294 Arif in Dhaka (First Love Part 2)题意:n颗珠子t种颜色 求有多少种项链和手镯 项链不可以翻转 手镯可以翻转思路:Polya定理  题目就是求等价类 项链只能旋转 手镯可以旋转也可以翻转根据定理 等价类的数量等于各个置换f的t^m(f)的平均数 m(f)是置换的循环节数 下面每次t^x x都是循环节数下面考虑手镯 旋转翻

2014-05-22 14:47:31 1446

转载 数学题集

1.burnside定理,polya计数法pku2409 Let it Bead   pku2154 Color  pku1286 Necklace of Beadspku2888 Magic Bracelet

2014-05-22 12:17:11 1115

转载 并查集&MST题集

【HDU】1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream'

2014-05-22 11:54:59 1359

原创 最小生成树模版

克鲁斯卡尔struct edge{ int u, v, w;}e[maxn];int f[110];bool cmp(edge a, edge b){ return a.w < b.w;}int find(int x){ if(x != f[x]) return f[x] = find(f[x]); return f[x];}int MST(){ int

2014-05-21 18:23:49 894

原创 Light OJ 1054 Efficient Pseudo Code 求n^m的约数和

题目来源:Light OJ 1054 Efficient Pseudo Code题意:求n的m次这个数的所有的约数和思路:首先对于一个数n = p1^a1*p2^a2*p3^a3*…*pk^ak  约束和s = (p1^0+p1^1+p1^2+…p1^a1)(p2^0+p2^1+p2^2+…p2^a2)…(pk^0+pk^1+pk^2+…pk^ak)然后就是先求素数表 分解因子 然后求

2014-05-20 19:59:34 1056

原创 Light OJ 1028 Trailing Zeroes (I) 求n因子数

题目来源:Light OJ 1028题意:求一个数转化成任意进制后末尾有0的种数 就是一个数因子的个数思路:一个数可以被分解成若干素数相乘 p1^x1*p2^x2*...*pn^xn 根据乘法原理 因子数为 (x1+1)*(x2+1)*...*(xn+1)注意剪枝#include #include #include #include using namespace st

2014-05-19 14:02:21 923

原创 湖南省第九届大学生程序设计竞赛

Interesting CalculatorCSU 过了 TOJ超时了 先记一下#include #include #include using namespace std;int a[100];bool b[100010];int c[100010];int d[100010];int x, y;int cas = 1;struct node{ int x, t,

2014-05-18 19:30:49 1382

原创 POJ 2689 Prime Distance 素数筛选法应用

题目来源:POJ 2689 Prime Distance题意:给出一个区间L R 区间内的距离最远和最近的2个素数 并且是相邻的 R-L 思路:一般素数筛选法是拿一个素数 然后它的2倍3倍4倍...都不是 然后这题可以直接从2的L/2倍开始它的L/2+1倍L/2+2倍...都不是素数首先筛选出一些素数 然后在以这些素数为基础 在L-R上在筛一次因为 R-L #include #i

2014-05-15 14:53:58 909

原创 UVa 991 Safe Salutations 卡特兰数

题目来源:UVa 991 Safe Salutations题意:圆上2*n个点均匀分布 两两相连 求不相交的方案数思路:卡特兰数的应用/*最典型的四类应用:(实质上却都一样,无非是递归等式的应用,就看你能不能分解问题写出递归式了)1.括号化问题。 矩阵链乘: P=a1×a2×a3×……×an,依据乘法结合律,不改变其顺序,只用括号表示成对的乘积,试问有几种括号化的方案?(h(n)

2014-05-14 12:54:54 1054

原创 UVa 10308 Roads in the North 树的直径

题目来源:UVa 10308 Roads in the North题意:求距离最远的2点之间的距离思路:裸的树的直径 或者树形DP#include #include #include using namespace std;const int maxn = 100010;struct node{ int to, w; node(){} node(int to, int

2014-05-13 20:09:21 895

原创 POJ 1006 Biorhythms 中国剩余定理

题目来源:POJ 1006 Biorhythms题意:给出3个周期第一次发生的时间 和 当前开始的天数 求三个周期下一次到达高峰期发生在哪一天思路:这题很水 试一下我的模版而已#include #include using namespace std;typedef long long LL;const int maxn = 10;int a[maxn], m[maxn];

2014-05-12 16:32:35 927

原创 POJ 2992 Divisors 求组合数因子个数

题目来源:POJ 2992 Divisors题意:。。。思路:素数分解的唯一性 一个数可以被分解成若干素数相乘 p1^x1*p2^x2*...*pn^xn根据乘法原理 因子数为 (x1+1)*(x2+1)*...*(xn+1)不能直接求出组合数 会溢出 也不能把每个乘的数分解因子 这样会超时C(N,M)=N!/(M!*(N-M)!)另dp[i][j] 代表为i的阶乘中j因子

2014-05-12 13:58:02 1047

原创 POJ 3090 Visible Lattice Points 法雷级数

题目来源:POJ 3090 Visible Lattice Points题意:哪些点可以看到思路:F1: 0/1 1/1 F2: 0/1 1/2 1/1 F3: 0/1 1/3 1/2 2/3 1/1 F4: 0/1 1/4 1/3 1/2 2/3 3/4 1/1 F5: 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1 F6:

2014-05-12 11:14:17 922

原创 POJ 2478 Farey Sequence 筛选法求欧拉函数

题目来源:POJ 2478 Farey Sequence题意:输入n 求 phi(2)+phi(3)+phi(4)+...+phi(n)思路:用类似筛法的方式计算phi(1), phi(2), ..., phi(n) 再求前缀和#include #include #include //欧拉phi函数 const int maxn = 1000010; typedef long

2014-05-11 19:58:00 907

转载 MyEclipse自动补全与快捷键设置

一般默认情况下,Eclipse ,MyEclipse的代码提示功能是比Microsoft Visual Studio的差很多的,主要是Eclipse ,MyEclipse本身有很多选项是默认关闭的,要开发者自己去手动配置。如果开发者不清楚的话,就不知道Eclipse ,MyEclipse的代码提示功能一样能像Microsoft Visual Studio的代码提示功能一样强大。先举个简单的例子

2014-05-10 20:18:08 1630

原创 数论模版

//求gcd(a, b) LL gcd(LL a, LL b){ return b ? gcd(b, a%b) : a;}  //求整数x和y,使得ax+by=d, 且|x|+|y|最小。其中d=gcd(a,b) void gcd(LL a, LL b, LL& d, LL& x, LL& y){ if(!b) { d = a; x = 1; y = 0

2014-05-10 16:57:00 1055

原创 1到N的平方和公式

1²+2²+...+n²=n(n+1)(2n+1)/6可以用数学归纳法证明1*2 + 2*3 + 3*4 + ... + n*(n+1) = (1²+1) + (2²+2) + (3²+3) + ... + (n²+n) = (1²+2²+3²+...+n²) + (1+2+3+...+n) = n(n+1)(2n+1)/6 + n(n+1)/2 = [n(n+1)/6]

2014-05-10 16:19:36 19753

原创 POJ 3047 Bovine Birthday 给出年月日求星期 蔡勒公式

题目来源:POJ 3047 Bovine Birthday题意:。。。思路:蔡勒公式 适合于1582年(中国明朝万历十年)10月15日之后的情形公式 w = y + y/4 + c/4 - 2*c + 26 * (m+1)/10 + d - 1;m如果是1 2 月份 y要倒退1年 m += 12y是年份的后两位 y = year%100c是世纪 c = year/100

2014-05-10 15:53:20 1202

原创 HDU 3081 Marriage Match II 二分+最大流

题目来源:HDU 3081 Marriage Match II题意:思路: 错误代码 纠结不知道哪错了 先放一放 #include #include #include #include #include using namespace std;const int maxn = 1010;const int INF = 999999999;struct Edg

2014-05-08 17:46:58 858

原创 HDU 4240 Route Redundancy 一条流最大的路径

题目来源:HDU 4240 Route Redundancy题意:求最大流与一条流最大的路径的比值 前者最大流求出 后者是每一条路的最小值再取大思路:我用的是dinic 可以在DFS的时候在传递一个参数 表示当前增广路可以通过最大的流量 然后当x==t 到达汇点时 在取他们的最大值#include #include #include #include #include usi

2014-05-08 09:06:11 976

原创 HDU 4183 Pahom on Water 来回走不重复点的网络流

题目来源:HDU 4183 Pahom on Water题意:若干个区域 每个区域有一个值 区域是圆 给出圆心和半径 从起点(值为400.0)到终点(值为789.0)满足走相交的圆 并且值必须递增 然后从终点到起点 值必须递减 此外区域只能去一次思路:建图 相互能走的区域连一条边 因为只能走一次 所以拆点 如果没有来回 只有去 那么判断最大流为1即可 现在还要回来 并且回来的条件和

2014-05-07 21:41:56 1065

原创 网络流模版

递归版struct Edge{ int from, to, cap, flow; Edge(){} Edge(int from, int to, int cap, int flow) : from(from), to(to), cap(cap), flow(flow){}};int n, m, s, t;vector edges;vector G[maxn];bool v

2014-05-06 14:48:09 904

转载 网络流题集

【HDU】1532Drainage Ditches(基础)    [最大流]3549 Flow Problem(基础)    [最大流]3572 Task Schedule    [最大流]任务分配,判断满流2732 Leapin' Lizards(难)    [最大流]3338 Kakuro Extension    [最大流][数和]神奇最大流行进列出2883 keba

2014-05-05 18:49:44 995

原创 HDU 1542 Atlantis 矩形面积并

题目来源:HDU 1542 Atlantis题意:给你一些矩形(左下角和右上角)求面积思路:参考here这个超赞的 一看就懂了#include #include #include #include using namespace std;const int maxn = 210;struct node{ double l, r, h; int s, val; nod

2014-05-05 17:32:42 938

原创 CF 427D Match & Catch 求最短唯一连续LCS

题目来源:CF 427D Match & Catch题意:给出2个字符串 求最短的连续的公共字符串 并且该字符串在原串中只出现一次思路:把2个字符串合并起来求height 后缀数组height的应用#include #include #include using namespace std;const int maxn = 100010;char s[maxn];int s

2014-05-03 22:47:22 1110

原创 POJ 2528 Mayor's posters 线段树成段更新+离散化

题目来源:POJ 2528 Mayor's posters题意:很多张海报贴在墙上 求可以看到几张海报 看那两张图就行了 第一张俯视图思路:最多2W个不同的数 离散化一下 然后成段更新 a[rt] = i代表这个区间是第i张报纸 更新玩之后一次query cover[i]=1代表可以看到第i张报纸#include #include #include using namespace

2014-05-01 22:05:02 975

ACM 学习资料

ACM 学习资料 包括一些压缩包 和 数据结构的一点东西

2013-11-29

数据结构课件

数据结构的课件 感觉比书上的代码容易理解

2013-09-04

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除