上一页 1 ··· 60 61 62 63 64 65 66 67 68 ··· 182 下一页
摘要: 题意:一个船能乘2人,船的运行速度为2人中较慢一人的速度,问把n个人运到对岸,最少需要多久。分析:我们设最快的为a,次快的为b,最慢的为z,次慢的为y。我们先考虑如何将y,z运到对岸,可以ab,a,yz,b(yz一起运),也可以ay,a,az,a(yz分开运)。我们这两种情况都是只考虑y,z,没考虑x的,那如果y需要和x一起运怎么办呢(x是第三慢的人)一起运yz时间:b+a+z+b,分开运时间:y+a+z+a比较二者大小只需比较2*b和y+a的大小。我们假设单运较快则2*b>y+a,y>x => y+a>x+a => 2*b>y+a>x+a => 阅读全文
posted @ 2011-10-10 18:50 undefined2024 阅读(331) 评论(0) 推荐(0)
摘要: 记忆化搜索View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 100005#define maxm 1000005struct Edge{ int v, next;}edge[maxm];int n, m;int value[maxn];int in[maxn], out[maxn];int head[maxn], ecount;long long f[maxn];boo 阅读全文
posted @ 2011-10-10 18:22 undefined2024 阅读(335) 评论(0) 推荐(0)
摘要: dpView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 105#define inf 0x3f3f3f3fint map[maxn][maxn];int income[maxn][maxn];int n, m;int f[maxn][maxn];void input(){ for (int i = 0; i < n; i++) for (int j = 0; j & 阅读全文
posted @ 2011-10-09 17:09 undefined2024 阅读(162) 评论(0) 推荐(0)
摘要: 简单题, BFSView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 105struct Point{ int x, y; Point() { } Point(int xx, int yy): x(xx), y(yy) { }}q[maxn * maxn];int n;int map[maxn][maxn];bool vis[maxn][maxn];int dir[4][2 阅读全文
posted @ 2011-10-09 13:43 undefined2024 阅读(177) 评论(0) 推荐(0)
摘要: 记忆化搜索View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int f[] = {1, 0, 6, 12, 90, 360, 2040, 10080, 54810, 290640, 1588356, 8676360, 47977776, 266378112, 1488801600};int n;int main(){ //freopen("t.txt", "r&qu 阅读全文
posted @ 2011-10-09 13:08 undefined2024 阅读(330) 评论(0) 推荐(0)
上一页 1 ··· 60 61 62 63 64 65 66 67 68 ··· 182 下一页