POJ2502 Subway flody
来源:互联网 发布:mac虚拟机怎么用 编辑:程序博客网 时间:2024/05/16 10:37
/*floyd*/#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <iomanip>using namespace std;const int maxn = 205;const int inf = 1 << 30;double g[maxn][maxn];int c;struct node {double x, y;};node s[maxn];double walk(int i, int j){double len = sqrt((s[i].x - s[j].x) * (s[i].x - s[j].x) + (s[i].y - s[j].y) * (s[i].y - s[j].y));return 60 * len / 10000;}double subway(int i, int j){double len = sqrt((s[i].x - s[j].x) * (s[i].x - s[j].x) + (s[i].y - s[j].y) * (s[i].y - s[j].y));return 60 * len / 40000;}void floyd(){for (int k = 1; k <= c; ++k) {for (int i = 1; i <= c; ++i) {for (int j = 1; j <= c; ++j) {g[i][j] = min(g[i][j], g[i][k] + g[k][j]);}}}return;}int main(){while (cin >> s[1].x >> s[1].y >> s[2].x >> s[2].y) {g[1][2] = g[2][1] = walk(1, 2);int j = 0, x, y;c = 3;while (cin >> x >> y) {if (x == -1 && y == -1)j = 0;else {s[c].x = x; s[c].y = y;for (int i = 1; i < c - j; ++i)g[i][c] = g[c][i] = walk(i, c);for (int i = c - j; i < c; ++i)g[i][c] = g[c][i] = subway(i, c);j = 1; ++c;}}--c;floyd();printf("%.0f\n", g[1][2]);}return 0;}
0 0
- POJ2502 Subway flody
- poj2502 - Subway
- poj2502 SubWay
- Poj2502 Subway
- poj2502 Subway
- POJ2502 subway
- poj2502 Subway最短路
- POJ2502——Subway
- POJ2502 Subway(Floyd)
- POJ2502 Subway 最短路
- poj2502 subway dijkstra
- POJ2502 subway(spfa)
- poj 2502Subway flody
- POJ2502 Subway(最短路径)
- POJ2502 Subway -DIJKSTRA最短路练习
- POJ2502 Subway(最短路Floyed)
- 【最短路】POJ2502 SUBWAY (spfa)
- POJ2502 subway(dijkstra以最短时间代替最短路)
- Don't believe false alarms about Docker containers
- 体验《消灭星星》之移植《星星》
- 简单的QSpinbox和Qslider
- android MediaRecorder start failed: -2147483648
- Spring中的AOP
- POJ2502 Subway flody
- ubuntu MySQL安装及本机MySQL front 远程连接经验
- 解决织梦(DedeCMS)系统自定义字段图片调用问题
- rsync+Inotify实现数据的实时同步更新
- Android中播放声音的两种方法
- EL表达式...jstl标签
- C#引用DLL
- poj2593
- floyd算法的应用1