POJ 1860 Currency Exchange Bellman判断正环
来源:互联网 发布:php session用法 编辑:程序博客网 时间:2024/06/05 07:30
这几天做最短路反正挺蒙b的~~~~~~
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>using namespace std;struct node{ int u, v; double w, r;}p[10000],t;int n, m, s;double v;double dis[2100];int g;int Bellman(){ int i, j; for(i = 1;i <= n;i++) dis[i] = 0; dis[s] = v; for(i = 1;i <= n;i++){ for(j = 0;j < g;j++){ t = p[j]; if(dis[t.v] < (dis[t.u] - t.r)*t.w){ dis[t.v] = (dis[t.u] - t.r)*t.w; if(i == n) return 1; } } } return 0;}int main(){ while(cin >> n >> m >> s >> v){ int a, b; double c, d, e, f; g = 0; while(m--){ scanf("%d %d %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f); p[g].u = a; p[g].v = b; p[g].w = c; p[g].r = d; g++; p[g].u = b; p[g].v = a; p[g].w = e; p[g].r = f; g++; } if(Bellman()){ printf("YES\n"); }else { printf("NO\n"); } } return 0;}
0 0
- POJ 1860 Currency Exchange Bellman判断正环
- POJ 1860 Currency Exchange(Bellman-Ford判断最长路是否含有正环)
- POJ 1860 Currency Exchange(SPFA 判断有无“正”环)
- POJ 1860 Currency Exchange Bellman
- poj 1860 Currency Exchange (bellman)
- poj-1860-Currency Exchange-Bellman
- poj 1860 Currency Exchange bellman
- POJ-1860-Currency Exchange(bellman)
- POJ 1860 - Currency Exchange(SPFA正环)
- poj 1860 Currency Exchange 3259 Wormholes bellman 判环
- POJ 1860 Currency Exchange Bellman-Ford
- POJ-1860-Currency Exchange-Bellman-ford
- poj 1860 Currency Exchange :bellman-ford
- POJ 1860 Currency Exchange(Bellman-Ford)
- POJ 1860 Currency Exchange(Bellman-Ford)
- poj 1860 Currency Exchange(bellman-ford)
- Bellman-Ford-POJ-1860-Currency Exchange
- POJ 1860 Currency Exchange(Bellman-Ford)
- bzoj 4621: Tc605 动态规划
- 数据结构实验之串二:字符串匹配
- 变更设计的流程
- 【C++11】随机数函数库random
- 7. PHP接入支付宝有密批量转款接口
- POJ 1860 Currency Exchange Bellman判断正环
- 与Service交互的三种方式
- php之从数据库中获取数据实例
- ios性能优化一
- Java基础编程题(7.31)
- 数据结构实验之栈三:后缀式求值
- Linux系统的shell命令--基础篇
- NOJ 1642 湖南省赛
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference