自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (1)
  • 收藏
  • 关注

原创 UVA 10723 Cyborg Genes——lcs

两个串a、b按照题目要求合成的串c的长度一定为lena+lenb-lcs(a,b),其中lcs(a,b)表示a、b的最长公共子序列。求解长度为lenc的串的数量可在普通lcs求解基础上加上一个cnt,cnt【i】【j】表示用串a前i个,串b前j个合成串c且串c长度最短时的情况数,然后就会有如下情况:1.当a【i】!=b【j】时,dp【i】【j】=max(dp【i-1】【j】,dp【i】)【j-1】...

2018-02-25 18:49:10 190

原创 UVA 242 Stamps and Envelope Size——完全背包

价值和重量调换过来进行完全背包,注意输出格式#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int INF = 0x3f3f3f3f;int S, N;struct Set { ...

2018-02-25 13:02:16 286

转载 博弈入门

原文:http://www.cnblogs.com/kuangbin/archive/2011/08/28/2156426.html有一种很有意思的游戏,就是有物体若干堆,可以是火柴棍或是围棋子等等均可。两个人轮流从堆中取物体若干,规定最后取光物体者取胜。这是我国民间很古老的一个游戏,别看这游戏极其简单,却蕴含着深刻的数学原理。下面我们来分析一下要如何才能够取胜。(一)巴什博奕(Bash Game...

2018-02-24 20:44:16 348

原创 POJ 2348 Euclid's Game——博弈

b-a>a为必胜态,所以问题就转化为看谁先达到这个状态#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int a, b;void solve() { bool f = true; ...

2018-02-24 10:31:16 201

原创 POJ 2187 Beauty Contest——凸包

因为点都是整点,所以这些点构成的凸包的顶点不会超过根号(m)个,m为坐标系的范围,因此只要构造出凸包二重循环枚举就可以了,另外当m太大时可以用旋转卡壳做,这里就不写了,以后有时间会补上#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#inclu...

2018-02-20 17:06:06 238

原创 POJ 2932 Coneology——扫描线

乍一看还以为线段树+扫描线,仔细想想虽然不是一个东西但是相似性很高,只要维护一下与扫描线相交的最外层圆就可以了,这里用了set,第一次写写得则乱,后来看了挑战程序设计才简化了代码,骚操作学到了#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#i...

2018-02-20 16:14:17 282

原创 POJ 1127 Jack Straws——线段相交

水题了,发现不了错误的话看看输入有没有问题#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int maxn = 100;const doubl...

2018-02-19 10:28:58 237

原创 POJ 3680 Intervals——dp+最小费用流

通过区间图最大权独立集的状态转移方程可以推断出建图方法,然后跑最小费用流,这里用了满流法来处理负权问题,说实在作为挑战程序设计网络流章最后一个题还是有一定难度的,至少我看了题解以后还似懂非懂,等我再接触一些网络流后会回来重新做这个题#include <cstdio>#include <cstring>#include <iostream>#include ...

2018-02-19 00:20:34 254

原创 POJ 3686 The Windy's——指派问题

假设用一个厂来处理所有物品,很容易推出总时间T=n*t1+(n-1)*t2+...+1*tn,根据这个式子我们可以把一个处理n个物品的厂看做n个处理一个物品的厂,处理时间分别乘n、n-1...1,这样的话最终有n个物品和n*m个厂,且这n*m个厂都是只能处理一个物品,典型的指派问题,增加源点汇点建图后跑一遍最小费用流即可,顺便再次注意一下c++和g++的区别——g++用.f,c++用.lf#inc...

2018-02-18 23:17:34 339

原创 POJ 2175 Evacuation Plan——消负圈算法求费用流

这道题普通的连续最短路算法会超时,我们发现题目不需要求最小的费用流,只需要求一个较小的费用流就可以,所以通过消负圈算法高效求解#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include &l...

2018-02-18 22:25:19 295

原创 POJ 2135 Farm Tour——最小费用流

跑一个流量为2的最小费用流,顺利1A#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>using namespace std;const int ma...

2018-02-18 13:50:18 237

原创 POJ 3469 Dual Core CPU——最小割最大流

while ((f = dfs(s, t, INF)) > 0) flow += f;模板里这个地方推荐加一个括号,不然有的编译器会有问题#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#i...

2018-02-18 12:01:02 194

原创 POJ 3281 Dining——最大流

挑战程序设计P235#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>using namespace std;const int maxn = 100...

2018-02-18 10:53:04 264

原创 POJ 3057 Evacuation——二分图匹配

思路挺巧妙,推荐看一下挑战程序设计P233,额。。。写的时候vis数组和used数组搞混了,最近怎么总是犯这种错误。。。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <q...

2018-02-18 00:56:55 237

原创 POJ 3041 Asteroids——二分图匹配

把激光看做点,星星看做边建图#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>using namespace std;const int maxn = 1010;int n, m;vector...

2018-02-17 20:31:23 209

原创 POJ 1769 Minimizing maximizer——线段树+dp

思路比较简单,然而线段树多写了一个else改了半天,感觉自己真TM的棒#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 5e4 + 10;const int maxm ...

2018-02-16 22:15:29 265

原创 POJ 3233 Matrix Power Series——矩阵快速幂

挑战程序设计P205,重点是构造出新的矩阵#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 100;int n, k, m;struct Matrix { i...

2018-02-16 15:34:52 212

原创 POJ 3734 Blocks——矩阵快速幂

挑战程序设计P203,重点是求递推式#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 5;const int mod = 10007;int T, n;struct...

2018-02-16 14:17:21 236

原创 HDU 1575 Tr A——矩阵快速幂

模板题#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 15;const int mod = 9973;int T, n, k;struct Matrix { ...

2018-02-14 14:13:20 217

原创 HDU - 1757 A Simple Math Problem——矩阵快速幂

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int k, m;struct Matrix { int mat[15][15]; Matrix() { memset(mat, 0, ...

2018-02-14 13:47:55 235

原创 矩阵快速幂模板

#define maxn 10+5;typedef long long ll;const ll mod = 1e9+7;#define clr(x,y) memset(x,y,sizeof(x))struct matrix { int n; ll maze[maxn][maxn]; void init(int n) { this->n=n; clr(maze,0);...

2018-02-13 21:53:15 130

原创 POJ - 2686 Traveling by Stagecoach——状压dp

用g++的话注意输出用。3f而不是。3lf,用c++的话就没问题了#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>using namespace std;typedef pair<int,...

2018-02-13 20:26:09 207

原创 POJ 2104 K-th Number——分块平方分割

区间推荐左闭右开#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>using namespace std;const int maxn = 1e5+10;const int len = 1000...

2018-02-13 01:08:32 394

原创 Crane POJ2991——线段树+几何

由于向量的可叠加性,这道题可以用线段树维护,配合一些几何的知识,代码还是挺好写的。然而因为一个括号忘了去卡了好几个小时 ((٩(//̀Д/́/)۶)) ,果然应了那句话,改越久的BUG往往越ZZ#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#...

2018-02-09 00:45:23 332

原创 POJ 2976 Dropping tests——最大化平均值

注意n=k=0时break#include #include #include #include using namespace std;const int maxn = 1010;int n, k, a[maxn], b[maxn];double y[maxn];bool judge(double t) { for (int i = 1; i <= n; i++)

2018-02-07 21:21:53 244

原创 POJ 3723 Conscription——最小生成树

边权取反,跑一遍MST,然后加上10000*(n+m),注意编号问题#include #include #include #include using namespace std;const int maxn = 50005;struct Edge { int u, v, cost; bool operator < (const Edge &e) const {

2018-02-04 12:09:31 285

原创 POJ 3255 Roadblocks——次短路

这个博主写得很清楚#include #include #include #include #include #include using namespace std;typedef pair P;const int maxn = 1e4;const int maxm = 250000;const int INF = 0x3f3f3f3f;int n, m, tot, he

2018-02-04 10:55:42 267

Qt游戏编程——飞机大战

游戏模板,大家可以随意添加自己的元素

2017-07-06

空空如也

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

TA关注的人

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