上一页 1 2 3 4 5 6 7 8 ··· 13 下一页

2014年10月29日

最小堆算法

摘要: 最小堆算法: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std; 11 12 #def... 阅读全文

posted @ 2014-10-29 13:07 深蓝无忌 阅读(739) 评论(0) 推荐(0) 编辑

并查集算法

摘要: 擒贼先擒王 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std;11 12 #define loop(i,n)... 阅读全文

posted @ 2014-10-29 11:06 深蓝无忌 阅读(189) 评论(0) 推荐(0) 编辑

2014年10月25日

dijkstra算法演示

摘要: dijkstra算法演示精髓#include #include #include #include #include #include #include #include using namespace std;#define loop(i,n) for(int i=0;idis[u]+e[u][v... 阅读全文

posted @ 2014-10-25 16:33 深蓝无忌 阅读(392) 评论(0) 推荐(0) 编辑

2014年10月24日

DFS与BFS应用于小哈迷宫

摘要: DFS与BFS均能胜任此途:#include #include #include #include #include #include #include #include using namespace std;#define loop(i,n) for(int i=0;in || tym) //判... 阅读全文

posted @ 2014-10-24 14:13 深蓝无忌 阅读(241) 评论(0) 推荐(0) 编辑

2014年10月22日

最易懂的DFS算法

摘要: 这是世界上最易懂的算法,呵呵,来自啊哈算法。#include using namespace std; int a[10],book[10],n;int total;void dfs(int step) //step表示站在第几个盒子面前{ if(step==n+1) //如果站在第n+1个盒... 阅读全文

posted @ 2014-10-22 21:09 深蓝无忌 阅读(577) 评论(0) 推荐(0) 编辑

2014年10月21日

usaco-5.3-milk4-passed

摘要: 这个要用动态规划,呵呵:这道题要用到迭代加深搜索(DFSID)。由于要求输出的是使用最少的牛奶桶,所以要先找牛奶桶数量为1的时候所有的组合,如果没有解再找牛奶桶数量为2...直到牛奶桶数量为P。当搜索到一个组合,判断用这些牛奶桶是否能组成目标解的时候,可以用动态规划的方法来做。设f[i]是当需求的牛... 阅读全文

posted @ 2014-10-21 21:26 深蓝无忌 阅读(247) 评论(0) 推荐(0) 编辑

usaco-1.3-skidesign-passed

摘要: brute force:(0,17),(1,18)....(83,100)/*ID: qq104801LANG: C++TASK: skidesignQQ:104804687*/#include #include #include #include #include #include #includ... 阅读全文

posted @ 2014-10-21 16:24 深蓝无忌 阅读(297) 评论(0) 推荐(0) 编辑

usaco-1.3-wormhole

摘要: 这个属于DFS枚举:/*ID: qq104801LANG: C++TASK: wormholeQQ:104804687*/#include #include #include #include #include #include #include #include using namespace s... 阅读全文

posted @ 2014-10-21 15:52 深蓝无忌 阅读(426) 评论(0) 推荐(0) 编辑

2014年10月3日

usaco-1.3-combo-pass

摘要: 水题,极水,列举,但要小心哦,开始判断那用了个循环,居然从249变成了250,查找了好一会才明白,条件复用是有条件的,虽然代码看起来漂亮了,但结果不对,又有何用。居然从第五层跳回第一层了,不知道为什么,呵呵:/*ID: qq104801LANG: C++TASK: comboQQ:104804687... 阅读全文

posted @ 2014-10-03 11:46 深蓝无忌 阅读(235) 评论(0) 推荐(0) 编辑

2014年10月1日

usaco-5.2-snail-passed

摘要: 有点水:/*ID: qq104801LANG: C++TASK: snailQQ:104804687*/#include #include #include #include #include #include #include #include using namespace std;#defin... 阅读全文

posted @ 2014-10-01 18:46 深蓝无忌 阅读(205) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 13 下一页

导航