POJ1860
来源:互联网 发布:淘宝店一件代销赚钱吗 编辑:程序博客网 时间:2024/06/05 18:01
#include <iostream>using namespace std;#include <cmath>#include <cstdlib>#include <cstdio>#include <string.h>#include <stack>int n,m,s;double v;int all;class excel{public: int a; int b; double r; double c;}exc[202];double dis[292]={0};bool bellmanford(){ memset(dis,0,sizeof(dis)); dis[s]=v; bool flag; for(int i=0;i<n-1;i++) { flag=false; for(int j=0;j<all;j++) { if(dis[exc[j].b]<(dis[exc[j].a]-exc[j].c)*exc[j].r) { dis[exc[j].b]=(dis[exc[j].a]-exc[j].c)*exc[j].r; flag=true; } } if(!flag) break; } for(int j=0;j<all;j++) { if(dis[exc[j].b]<(dis[exc[j].a]-exc[j].c)*exc[j].r) return true; } return false;}int main(){ double rab,cab,rba,cba; int a,b; while(cin>>n>>m>>s>>v) { all=0; for(int i=0;i<m;i++) { cin>>a>>b>>rab>>cab>>rba>>cba; exc[all].a=a; exc[all].b=b; exc[all].r=rab; exc[all++].c=cab; exc[all].a=b; exc[all].b=a; exc[all].r=rba; exc[all++].c=cba; } if(bellmanford()) printf("YES\n"); else printf("NO\n"); } //return 0;}
0 0
- poj1860
- poj1860
- poj1860
- poj1860
- poj1860
- poj1860
- poj1860
- poj1860
- POJ1860
- poj1860
- POJ1860
- poj1860
- POJ1860
- poj1860
- poj1860
- POJ1860
- bellman--poj1860
- POJ1860随感
- LeetCode_nextpermutations
- 第四天 我为集成平台狂-犀利严谨的Ant(二)
- 第十天3月3日之cookie和session的补充,session中的URL重新技术,base64编码和解码,MD5算法
- leetcode: 3Sum
- 初用Git
- POJ1860
- 关键地址迁移for L138
- demo1
- 蓝桥杯 最大数 递归 填空题 Java
- 由12306.cn谈谈网站性能技术
- 性能调优攻略
- 内部排序:冒泡排序算法
- 浅谈Android应用性能之启动时间
- cocos2d-x 2.2 android环境搭建