摘要: 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4318题目大意:讲的是西电东送。让你输入N代表N个点,然后再输入M代表可以到M个地方去,每个M钟有一个表示节点,一个表示耗电的百分比,。最后输入三个数,一个是起点,一个是重点,一个是总电量。然后算出最后到达终点使得总电量最大可以是多少,不能到达的话输出IMPOSSIBLE!这道题也就转化成了求最大的转化率。相当于最长路的计算。由于N<=50000数目比较大,所以估计邻接矩阵会超事,然后写了个邻接表的代码:#include <stdio.h>#include <string.h 阅读全文
posted @ 2012-08-15 20:10 某某。 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。SPFA算法是西南交通大学段凡丁于1994年发表的.很多时候,给定的图存在负权边,这时类似Dijkstra等算法便没有了用武之地,而Bellman-Ford算法的复杂度又过高,SPFA算法便派上用场了。 我们用数组d记录每个结点的最短路径估计值,而且用邻接表来存储图G。我们采取的方法是动态逼近法:设立一个先进先出的队列用来保存待优化的结点,优化时每次取出队首结点u,并且用u点当前的最短路径估计值对离开u点所指向的结点v进行松弛操作,如果v点的最短路径估计值有所调整,且v点不在当前的队列中,就将v点 阅读全文
posted @ 2012-08-15 16:09 某某。 阅读(392) 评论(0) 推荐(0) 编辑
摘要: pc代码View Code hdu 1147#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>using namespace std;const int N=1002;const double eps=0.0000000001;//注意设置一个精度struct node{ double ux,uy; double lx,ly; int num; bool tab;};queue<node> ss;double j 阅读全文
posted @ 2012-08-15 16:04 某某。 阅读(238) 评论(0) 推荐(0) 编辑
摘要: View Code #include <iostream>#include <stdio.h>using namespace std;typedef struct node{ double x; double y;}point;point p[105];point make_e(point x,point y){ point a; a.x = x.x - y.x; a.y = x.y - y.y; return a;}double cha(point x,point y){ return x.x*y.y - y.x*x.y;}int main(){ ... 阅读全文
posted @ 2012-08-15 15:51 某某。 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <stdio.h>using namespace std;typedef struct node{ double x; double y;}point;typedef struct ed{ point a; point b; int is_top;}edge;edge e[100005];point make_e(point x,point y){ point a; a.x = x.x - y.x; a.y = x.y - y.y; return a;}double cha(point... 阅读全文
posted @ 2012-08-15 15:47 某某。 阅读(263) 评论(0) 推荐(0) 编辑
摘要: * 需要包含的头文件 */#include <cmath >/* 常用的常量定义 */const double INF = 1E200const double EP = 1E-10const int MAXV = 300const double PI = 3.14159265/* 基本几何结构 */struct POINT{ double x; double y; POINT(double a=0, double b=0) { x=a; y=b;} //constructor};struct LINESEG{ POINT s; POINT e; LINESEG(POIN... 阅读全文
posted @ 2012-08-15 15:41 某某。 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目大意就是 你有足够多的坦克,让你用尽量多的坦克去占领电厂。有N+1各节点,0~n ,0为出发点,1~n为电厂。要想控制摧毁电厂,战胜对方,只需要占领一般的电量即可。但是特克会耗油,所一给你m条路,让你去计算最小耗电量~而且如果坦克不能通过m条路到达任意一个电厂的话就输出'impossible'连接:http://acm.hdu.edu.cn/showproblem.php?pid=3339代码:dijView Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 0x5fffff 阅读全文
posted @ 2012-08-15 10:56 某某。 阅读(165) 评论(0) 推荐(0) 编辑