上一页 1 ··· 5 6 7 8 9
摘要: 这道题算是01背包问题吧,刚开始做DP的题目,那这一题试试也很不错hand[j]=max(hand[j],hand[j-w[i]]+d[i]);#include #include using namespace std;int hand[12900];int w[3410],d[3410];int ... 阅读全文
posted @ 2014-07-17 10:34 Mr.XuJH 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 一个简单而经典的dp;若数组a:1 3 2 4则数组b:1 4 3 8b[i]每一个都要向前找 合法 的最大b[x]值加上当前的a[i];如b[2]=b[0]+a[2];#include using namespace std;int a[1001];int b[1001];int max_b(in... 阅读全文
posted @ 2014-07-16 22:15 Mr.XuJH 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目是数独,想到了深度优先搜索一个个地验证;做出来后,妈妈再也不用担心我玩数独被人虐了#include using namespace std;int num[10][10];int x,y;bool judge(int l,int r,int a){ //用于判断同一行,... 阅读全文
posted @ 2014-07-16 16:06 Mr.XuJH 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 这一题用了DFS对每一种方法进行尝试,直到有一种成功的就possible;#include #include "string.h"using namespace std;int diff;int card[26][4]; //用于记录不同卡片的上、右、下、左、方向的数字int ca... 阅读全文
posted @ 2014-07-16 10:55 Mr.XuJH 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 主要运用BFS把一个’@‘所在的油田的‘@’都标记(既改为‘*’),然后不断的找’@‘,重复刚才那一步,直到找不到’@‘为止;记录找的次数;#include #include #include "string.h"using namespace std;struct spot{public: int... 阅读全文
posted @ 2014-07-14 23:09 Mr.XuJH 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 利用广度优先搜索,对可以达到的“.”进行统计;每一个点对应有4个方向,每一个都去尝试#include #include #include using namespace std;struct tile{public: int x,y; void init(int nx,int ny){ x=nx; ... 阅读全文
posted @ 2014-07-14 17:30 Mr.XuJH 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 这一题主要用到了BFS广度优先算法 若马的当前位置为(x,y),那么下一步就有8种可能。(x+2 , y+1) , (x+1 , y+2 ) , (x-1 , y+2) , (x-2 , y+1)(x+2 , y -1) , (x+1 , y-2 ) , (x-1 , y-2) , (x-2 , y... 阅读全文
posted @ 2014-07-14 15:54 Mr.XuJH 阅读(130) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9