POJ 2253 floyd 最短路
来源:互联网 发布:淘宝怎么看权重 编辑:程序博客网 时间:2024/05/21 17:34
本想二分答案,后来发现只要修改floyd方程即可
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 222;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;double dist[N][N], op[N][N], d[N];int vis[N];int n;struct node{double x, y;}pt[N];double cal(double x1, double y1, double x2, double y2){return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}int main(){int cas = 1;while (scanf("%d", &n) != EOF && n){int i, j, k;double mid, l, r, t;for (i = 0; i < n; ++i){scanf("%lf%lf", &pt[i].x, &pt[i].y);}for (i = 0; i < n; ++i)for (j = 0; j < n; ++j){if (i == j) dist[i][j] = 0.0;if (i < j ) dist[i][j] = cal(pt[i].x, pt[i].y, pt[j].x, pt[j].y);if (i > j) dist[i][j] = dist[j][i];}for (k = 0; k < n; ++k)for (i = 0; i < n; ++i)for (j = i + 1; j < n; ++j){if (dist[i][j] > dist[i][k] && dist[i][j] > dist[k][j]){if (dist[i][k] < dist[k][j])dist[i][j] = dist[j][i] = dist[k][j];elsedist[i][j] = dist[j][i] = dist[i][k];}}printf("Scenario #%d\n", cas++);printf("Frog Distance = %.3lf\n\n", dist[0][1]);}return 0;}
- POJ 2253 floyd 最短路
- poj 2253 floyd最短路!!!
- poj 2253 Frogger (最短路Floyd)
- POJ 2253 Frogger(最短路 Floyd)
- POJ 2253 Frogger最短路(floyd)
- POJ 2253 Frogger(最短路--floyd变形)
- POJ 2253Frogger(最短路floyd)
- POJ 3165 最短路 floyd
- poj 1847 最短路 floyd
- POJ 1125 最短路 FLOYD
- POJ训练计划2253_Frogger(最短路/floyd)
- POJ 2253Frogger(翻译/最短路/floyd/思维)
- 文章标题 POJ 2253 : Frogger(最短路--Floyd)
- POJ 2253 Frogger(最短路变形,floyd算法)
- poj 2570 Fiber Network(最短路+Floyd)
- poj 2263 Heavy Cargo(最短路+floyd)
- POJ 3613 Cow Relays Floyd最短路
- POJ 1125 Stockbroker Grapevine(最短路&Floyd)
- JAVA中数据类型转换
- 正向代理和方向代理的异同点
- 输入一段字符串,把其全部转换成大写字母
- hibernate 的 使用 MyEclipse 工具生成 POJO 类和映射文件*.hbm.xml
- 游戏开发中常用的设计模式
- POJ 2253 floyd 最短路
- hdu 3488
- 那些人,珍重便好
- MSSQL 日期相关操作
- 在Spring、Hibernate中使用Ehcache缓存
- Yeslab现任明教教主数据中心Nexus课程 视频教程 下载
- linux 免密码 ssh 互相连接
- linux c 关闭回显
- 2013-08-18