- 博客(46)
- 资源 (4)
- 收藏
- 关注
原创 latex学习笔记之一(工具篇)
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.r
2016-12-25 14:28:55 909
原创 hdu2037 贪心 活动安排
#include #include #define N 100typedef struct{ int s; int t;}act;act buf[N];int cmp(void const *_x, void const *_y){ act *x = (act*)_x; act *y = (act*)_y; return x->t - y->t;}int ac
2014-11-15 23:47:56 525
原创 hud1025 最长递增子序列 dp
#include #include #define N 500000int buf[N];int dp[N];int biSearch(int *arr, int a, int b, int key){ int m; while(a <= b){ m = a + (b-a)/2; if(arr[m] < key)
2014-11-15 20:32:48 521
原创 hdu2602 01背包问题
#include #include #include #include #define N 1010int opt[N][N];int w[N];int v[N];int bestVal(int opt[][N], int *w, int *v, int m, int c){ int i, j, tmp; for(i = 0; i <= c; ++i) opt[0][i
2014-11-15 19:57:34 503
原创 zoj2107 最近点对问题 分治思想
//closest pair#include #include #include #define Max 100000#define Inf 0x7ffftypedef struct point{double x;double y;}point;point buffer[Max];point tmp[Max];int cmp(const void *a, const void *b){point
2014-11-01 17:35:14 599
原创 硬币问题 动态规划 算法入门经典
递归#include #include #define maxn 100#define maxm 100int d[maxn];int v[maxm];int s, n;int dpmin(int t){ int *ans = &d[t]; if(*ans != -1) return *ans; *ans = 1<<30; int j, tmp; for(j = 0;
2014-04-13 12:26:08 914
原创 嵌套矩形 DAG上的动态规划 算法入门经典
#include #include #define maxn 100int G[maxn][maxn];int d[maxn];typedef struct node{ int x, y;}node;node vex[maxn];int n;int cmp(int i, int j){ if(vex[i].x < vex[j].x && vex[i].y < vex[j].
2014-04-12 18:01:42 691
原创 数字三角形问题 算法入门经典
递归方法:#include #define maxn 100int buf[maxn][maxn];int n;int d(int i, int j){ int t1, t2; return i == n ? buf[i][j] : buf[i][j] + (((t1 = d(i+1, j)) > (t2 = d(i+1, j+1))) ? t1 : t2);}int ma
2014-04-11 17:58:00 1229
原创 倒水问题 算法入门经典
#include #include #include #define maxn 1001using namespace std;struct node{ int v1, v2, v3; int step; node operator = (node &t){ v1 = t.v1; v2 = t.v2; v3 = t.v3; step = t.step; }};
2014-04-05 13:45:35 2908
原创 hdu 1495非常可乐 bfs
#include #include #include #define maxn 101using namespace std;int visit[maxn][maxn];int s, n, m;struct node{ int x, y, z; int step; void operator = (node &t){ x = t.x; y = t.y; z = t
2014-04-05 12:57:50 427
原创 poj 1564 / zoj 1711 深搜 隐式图搜索
#include #define maxm 1000#define maxn 13int buf[maxn], t, ans[maxm][maxn], tmp[maxn], n, w;void judge(){ int i, j; for(i = 0; i < w; ++i){ if(tmp[0] != ans[i][0]) continue; for(j = 1; j <=
2014-04-02 14:50:20 478
原创 poj 1190 生日蛋糕 隐式图搜索
#include #include #define MIN(x, y) (x) < (y) ? (x) : (y)#define maxn 21#define INF 0x7fffint bstv[maxn];int bsts, m;void dfs(int f, int bufs, int bufv, int r, int h){ if(f == 0){ if(bufv =
2014-03-29 14:36:29 487
转载 hdu1997 汉诺塔
#include #define maxn 65int dfs(int n, int *x, int *y, int *z){ if(n == 0) return 1; if(y[0] && n == y[1]) return 0; if(x[0] && n == x[1]){ x[1] = x[0] - 1; dfs(n-1, ++x, z, y); } else if(
2014-03-25 10:22:47 375
原创 小小的愤怒
昨天和老孙一起吃饭了,能见到本尊很是开心啦。感觉老孙和爷爷奶奶一样很话很多呢,饭桌上都是他的话。。。后来老孙才意识到我们这些小辈的存在,后来又问了我们学校啊,经历神马的,后来我就觉得原来评价一个人最重要的可能不是看这个人的人品,性格,能力或者其他。。学校能说明很多,想想也是啦,但是这反而让我有点愤怒,有点想证明自己了,喜欢编程是慢慢喜欢的,因为喜欢才想着去读研究生,希望自己能慢慢融入这
2014-03-14 15:02:50 425
原创 算法入门经典 7.4.4 带宽问题 回溯 剪枝
#include #include #define maxn 10struct graph{int adj[maxn][maxn];int vex;}g;int vis[maxn];int deg[maxn];int perm[maxn];int bestperm[maxn];int bestw = maxn, maxw = -1;void search_width(int cur){int i;
2014-03-05 15:16:54 901
原创 zoj 1002 回溯
每次检测一个可以放置的位置,只需要在其所在行和所在列检测其是否在和其相邻最近的墙之间是否已经放置了blockcatle,然后就是回溯的思想去解决。#include #define maxn 4int vis[maxn][maxn];char map[maxn][maxn];int max;void dfs(int cur, int n){ int i, j; f
2014-02-26 18:25:47 714
原创 百练 2754八皇后问题
#include #define maxn 9 int c[maxn];int n, tot, x;void search(int cur){int i, j;if (cur > n){++tot; if(tot == x){for(j = 1; j <= n; ++j)printf("%d", c[j]);printf("\n");} return;} for(i = 1; i <= n; ++
2014-02-21 21:41:02 623
原创 poj2386 深搜 连通块问题
#include #include #define maxn 101char pool[maxn][maxn];int vis[maxn][maxn];int n, m;int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};void dfs(int x, int y)
2014-02-14 23:57:45 612
原创 poj 3620 深搜
#include #include #define maxn 101int n, m, k, count;int buf[maxn][maxn];int vis[maxn][maxn];int dir[8] = {-1, 0, 1, 0, 0, -1, 0, 1};void dfs(int x, int y){ int d; vis[x][y] = 1; +
2014-02-14 23:55:37 449
原创 深搜 拓扑排序
算法竞赛入门经典中深搜拓扑排序的实现#include #include #define maxn 20int vis[maxn];int topo[maxn];int t, n;int adj[maxn][maxn];int dfs(int u){ int v; vis[u] = -1; for(int v = 1; v <= n; ++v){
2014-02-05 13:15:10 723
原创 poj3984 迷宫问题
#include #include #define maxm 5#define maxn 5int maze[maxm][maxn];int vis[maxm][maxn];int fa[maxm][maxn];int q[maxm*maxn], front, rear;int stack[maxm*maxn], top;void bfs(int x,
2014-02-05 13:08:24 510
原创 hud1116
和poj2337类似,不需要输出路径,需要注意的是要记录单词首尾字母所对应的顶点,并非在一个case中26个字母都对应是顶点。#include #include #define maxn 26int tree[maxn];int degree[maxn];int vis[maxn];int findRoot(int u){ if(tree[u] == -1) r
2014-02-05 11:42:38 665
原创 hdu3018(gcc)
无向图欧拉路问题 首先确定连通分量的个数,如果是连通分量,则为强连通分量,即分量中的任意两个顶点均可存在至少一条路径可以到达,其次确定每个连通分量的欧拉路问题,如果连通分量内所有顶点的度数均为偶数,则必然存在一条欧拉回路,满足条件,否则,存在偶数个度数为奇数的顶点,因为设某个连通分量含有x条路径,则所有顶点的度数和为2x,若含有奇数个顶点度数为奇数,显然不满足,则可以将度数为奇数的顶点配对,则存
2014-02-05 10:51:48 645
原创 poj2337(gcc)
#include #include #include #define maxn 1001#define num 26typedef struct node{int next, adj;char word[21];}node;node adjlist[maxn];int adj[num];int deg[num];int vis[maxn];int top, stack[maxn];int tree
2014-02-04 10:59:08 625
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人