上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 25 下一页

2011年7月19日

hdu 1010 Tempter of the Bone

摘要: 这是一道关于迷宫的搜索题,注意看懂题意:必须在time=T的时候门才开,这个时候必须准时到达door才能survive,既不能早了,也不能晚了,有一个细节用到了奇偶剪枝原理#include<iostream>#include<cstdio>#include<cmath>#include<string.h>using namespace std;int N,M,T,OK;int startx,starty,endx,endy;char maze[8][8];int mark[8][8];int X[4]={1,-1,0,0};int Y[4]={0 阅读全文

posted @ 2011-07-19 13:31 lonelycatcher 阅读(186) 评论(0) 推荐(0) 编辑

2011年7月18日

HDU 今年暑假不AC

摘要: 典型的活动安排问题,先将活动按照结束时间进行排序。。。。#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;int N;struct show{ int start; int end;};show shows[110];int cmp(const void* a,const void* b){ show c=*(show*)a; show d=*(show*)b; if(c.end==d.end) { return c.start-d.start; } else ret 阅读全文

posted @ 2011-07-18 16:44 lonelycatcher 阅读(181) 评论(0) 推荐(0) 编辑

HDU 1009 Fatmouse's trade

摘要: 贪心+排序#include <iostream>#include<stdio.h>#include<algorithm>#include<math.h>using namespace std;int M,N;struct wareroom{ int Javabean; int catfood; double balance;};wareroom room[100000];int cmp(const void* a,const void* b){ wareroom c=*(wareroom*)a; wareroom d=*(wareroom*)b; 阅读全文

posted @ 2011-07-18 16:09 lonelycatcher 阅读(243) 评论(0) 推荐(0) 编辑

平面最近点对的分治算法

摘要: 上一页 | 返回目录 | 下一页最接近点对问题 转自参考解答 这个问题很容易理解,似乎也不难解决。我们只要将每一点与其他n-1个点的距离算出,找出达到最小距离的两个点即可。然而,这样做效率太低,需要O(n2)的计算时间。在问题的计算复杂性中我们可以看到,该问题的计算时间下界为Ω(nlogn)。这个下界引导我们去找问题的一个θ(nlogn)算法。 这个问题显然满足分治法的第一个和第二个适用条件,我们考虑将所给的平面上n个点的集合S分成2个子集S1和S2,每个子集中约有n/2个点,·然后在每个子集中递归地求其最接近的点对。在这里,一个关键的问题是如何实现分治法中的合并步骤,即由S1和S2 阅读全文

posted @ 2011-07-18 09:07 lonelycatcher 阅读(6901) 评论(0) 推荐(0) 编辑

2011年7月16日

HDU 1005 number sequence

摘要: 一道数学题,纠结了好长时间,10^8 的话,用O(N)的算法一定会超时,考虑到模7,是一个循环问题,重要的是找出循环节,注意不一定是从f[1]出开始循环。。。#include<iostream>#include<cstdio>using namespace std;int f[100];int A,B;long long N;int find(int left,int right){ for(int i=1;i<left;i++) { if(f[i]==f[left]&&f[i+1]==f[right])return i; } return 0;} 阅读全文

posted @ 2011-07-16 13:25 lonelycatcher 阅读(245) 评论(0) 推荐(0) 编辑

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 25 下一页

导航