![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
OJ
文章平均质量分 50
乐乐_J
这个作者很懒,什么都没留下…
展开
-
ZOJ 3321
图的“草根”解法#include#include int bsearch(int *A,int *B,int x1,int y1,int v){ int x=x1,y=y1,m; while(x { m=x+(y-x)/2;原创 2011-08-23 14:40:45 · 616 阅读 · 2 评论 -
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 · 364 阅读 · 0 评论 -
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 · 486 阅读 · 0 评论 -
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 · 398 阅读 · 0 评论 -
HDU 2001 2002
(1)2001#include#include int main(){ float x1,y1,x2,y2; while(scanf("%f%f%f%f",&x1,&y1,&x2,&y2)!=EOF) printf("%原创 2011-08-20 11:19:10 · 315 阅读 · 0 评论 -
HDU 2003 2004
(1) 2003 #include int main(){ double x,y; while(scanf("%lf",&x)!=EOF) { y=(x>=0)?x:(-x); p原创 2011-08-20 11:33:43 · 405 阅读 · 0 评论 -
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 · 509 阅读 · 0 评论 -
HDU 1089 1090 1091 1092 1093 1094 1095 1096
这是自己做的第一批ACM题目,现在看来很简单,但作为入门题目,让我渐渐熟悉ACM在输入输出方面的一些技巧,其实对于输入数据的考虑对于程序的设计是非常重要的,尤其是一些边缘数据和特别数据,注意数据的初始化,以及题目对于输出格式的要求。希望这个能对新手有些帮助。。。(1)1089原创 2011-08-19 14:54:32 · 1355 阅读 · 4 评论 -
HDU 2000
#include int main(){ char a,b,c,t; while(scanf("%c%c%c",&a,&b,&c)!=EOF) { getchar();原创 2011-08-20 11:09:16 · 363 阅读 · 0 评论 -
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 · 633 阅读 · 0 评论 -
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 · 511 阅读 · 0 评论 -
hdu3018(gcc)
无向图欧拉路问题 首先确定连通分量的个数,如果是连通分量,则为强连通分量,即分量中的任意两个顶点均可存在至少一条路径可以到达,其次确定每个连通分量的欧拉路问题,如果连通分量内所有顶点的度数均为偶数,则必然存在一条欧拉回路,满足条件,否则,存在偶数个度数为奇数的顶点,因为设某个连通分量含有x条路径,则所有顶点的度数和为2x,若含有奇数个顶点度数为奇数,显然不满足,则可以将度数为奇数的顶点配对,则存原创 2014-02-05 10:51:48 · 611 阅读 · 0 评论 -
倒水问题 算法入门经典
#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 · 2898 阅读 · 0 评论 -
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 · 700 阅读 · 0 评论 -
ZOJ3197
git@code.csdn.net:snippets/161777.git原创 2014-01-18 12:42:48 · 522 阅读 · 0 评论 -
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 · 567 阅读 · 0 评论