2009年4月23日

8数码

摘要: 8数码问题解决方案(转) 8数码问题 问题简介: 所谓八数码问题是指这样一种游戏:将分别标有数字1,2,3,…,8的八块正方形数码牌任意地放在一块3×3的数码盘上。放牌时要求不能重叠。于是,在 3×3的数码盘上出现了一个空格。现在要求按照每次只能将与空格相邻的数码牌与空格交换的原则,将任意摆放的数码盘逐步摆成某种特殊的排列。如下图表示了 一个具体的八数码问题求解。问题分析: ... 阅读全文

posted @ 2009-04-23 21:06 ZAFU_VA 阅读(425) 评论(0) 推荐(0) 编辑

2009年4月21日

sum(a[i]|a[j])

摘要: //sum((n*n-(n-b[i])^2)*2^i) #include using namespace std;int main(){ int b[100]; int a[10010]; int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); mem... 阅读全文

posted @ 2009-04-21 16:15 ZAFU_VA 阅读(246) 评论(0) 推荐(0) 编辑

pku 1010 dfs

摘要: //dfs 做了两天 调试了半天 发现va 是关键字说 突然变0了 自己ubuntu上的g++题目给的数据都没过 提交竟ac了说 #include #include using namespace std;int value[10010], customer[10010], cnt[50];int av, result, types, flag, maxvalue, re[4];int ret... 阅读全文

posted @ 2009-04-21 15:57 ZAFU_VA 阅读(382) 评论(0) 推荐(0) 编辑

2009年4月18日

别人问的倒牛奶问题 暴搜

摘要: #include #include using namespace std;int n[3], c, k;int re[10010][3];bool hash[100][100][100];class Node{ public : int N[3]; Node *pre;};Node node[10010];void bfs(){ queue Q; ... 阅读全文

posted @ 2009-04-18 17:20 ZAFU_VA 阅读(198) 评论(0) 推荐(0) 编辑

2009年4月15日

hdu 2389 二分匹配

摘要: #include #include using namespace std;vector > V, guest;vector > where;vector hash;vector list1, list2;int T, t, n, m, cnt = 1;int pf(int a){ return a * a;}bool dfs(int a){ if (hash[a]) {... 阅读全文

posted @ 2009-04-15 21:34 ZAFU_VA 阅读(326) 评论(0) 推荐(0) 编辑

2009年4月14日

fzu 1698 大数

摘要: //大数#include using namespace std;const int MAXN = 100000;int main(){ int n, m, j, i; int a[5000]; while (scanf("%d", &n) != EOF) { if (n == 3) { printf("1 2\n2\n")... 阅读全文

posted @ 2009-04-14 21:25 ZAFU_VA 阅读(155) 评论(0) 推荐(0) 编辑

fzu 1700 数学公式

摘要: //郁闷的题目 郁闷的oj 公式题 xp上敲的时候不行 换了g++ 加了个0.5 过了说 #include using namespace std;int main(){ int a, d; long long i, s; while (scanf("%d %d %lld", &a, &d, &i) != EOF) { i = i%2009; i... 阅读全文

posted @ 2009-04-14 21:22 ZAFU_VA 阅读(145) 评论(0) 推荐(0) 编辑

2009年3月31日

hdu 1180 (bfs)

摘要: #include #include using namespace std; class Node { public : int x, y, time; }; Node first, next; int dir[4][2] = {{0,1},{0,-1},{1,0},{-1,0}}; int n, m, a, b; char map[21][21]; bool has... 阅读全文

posted @ 2009-03-31 22:33 ZAFU_VA 阅读(810) 评论(0) 推荐(1) 编辑

hdu 1242 优先队列+bfs

摘要: //第一次敲优先队列 #include #include #include using namespace std; class Node { public : int x, y, time; friend bool operator b.time; } }; priority_queue Q; Node first, next... 阅读全文

posted @ 2009-03-31 20:32 ZAFU_VA 阅读(928) 评论(0) 推荐(0) 编辑

导航