摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1196这道题也是搜索题,还是dfs,我们只需对最后一行进行搜索,然后找到能爬到的最高高度即可,每走一步我们就计算一次现在处于的高度h,然后与maxh比较。因为开始少写了一句memset而WA了一遍...#include<stdio.h>#include<string.h>#define N 105int dx[] = { 0, 0, 1, -1};int dy[] = { 1, -1, 0, 0};int map[N][N], vis[N][N];int n, m;int 阅读全文
posted @ 2011-11-10 10:45
找回失去的
阅读(264)
评论(0)
推荐(0)
摘要:
这道题是一道搜索题,要我们找有多少块不同的油田,@与其相邻的八个方向的@属于同一片油田,我选择用dfs来做。#include<stdio.h>#include<string.h>#define N 105int map[N][N], vis[N][N];char str[N];int dx[] = { -1, 1, 0, 0, -1, -1, 1, 1};int dy[] = { 0, 0, -1, 1, -1, 1, -1, 1};void dfs( int x, int y){ int newx, newy; for( int i = 0; i < 8; i 阅读全文
posted @ 2011-11-10 09:50
找回失去的
阅读(201)
评论(0)
推荐(0)
摘要:
这道题是基础背包问题,我们手里有n块钱,然后求n块钱能买到的最大葡萄个数,价格为j的一串葡萄有除开j本身外其所有约数之和个葡萄。先将每串葡萄的个数求出来,再用状态转移方程,dp[i] = max( dp[i], dp[n - j] +w[j])即可,i从n到0。#include<stdio.h>#include<string.h>#define N 26using namespace std;int w[N];int dp[N];int max( int a, int b){ return a > b ? a : b;}int f( int n){ int sum 阅读全文
posted @ 2011-11-10 09:17
找回失去的
阅读(200)
评论(0)
推荐(0)
浙公网安备 33010602011771号