POJ 2240 Arbitrage( floyd)
来源:互联网 发布:怎么逛淘宝店铺街 编辑:程序博客网 时间:2024/04/30 05:57
大概意思就是先给出n中货币的名字,然后给出m种汇率,A C B,代表1单位的A可以换C单位的B.问是否存在一种方法可以使得某种方法,使自身换到是自身汇率能大于1....字符串输入有点...麻烦?也不算难...像是POJ 1860的弱化版?floyd可以直接跑出来的样子...
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<iostream>#include<algorithm>using namespace std;char name[50],s[50][50];;int n;double map[50][50];int find(){ for(int i=1; i<=n; i++) if(strcmp(s[i],name)==0) return i;}int main(){ int m,cas=1; while(cin>>n,n) { for(int i=1; i<=n; i++) { scanf("%s",s[i]); } cin>>m; memset(map,0,sizeof(map)); for(int i=1; i<=n; i++) { map[i][i]=1.0; } for(int i=0; i<m; i++) { int a,b; double c; scanf("%s",name); a=find(); cin>>c; scanf("%s",name); b=find(); map[a][b]=c; } for(int k=1; k<=n; k++) { for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) map[i][j]=max(map[i][j],map[i][k]*map[k][j]); } } int flag=0; for(int i=1; i<=n; i++) { if(map[i][i]>1.0) flag=1; } if(flag) printf("Case %d: Yes\n",cas); else printf("Case %d: No\n",cas); cas++; } return 0;}
0 0
- POJ 2240 Arbitrage(Floyd)
- poj 2240 Arbitrage (Floyd)
- POJ 2240 Arbitrage(Floyd)
- POJ 2240 Arbitrage( floyd)
- POJ -- 2240 Arbitrage (Floyd‘)
- POJ 2240 Arbitrage (Floyd)
- POJ - 2240 Arbitrage(Floyd)
- POJ 2240 Arbitrage (Floyd)
- poj 2240Arbitrage(Floyd)
- POJ 2240 Arbitrage Floyd
- POJ 2240 Arbitrage(Floyd)
- POJ 2240 Arbitrage floyd
- poj 2240 Arbitrage 【floyd】
- POJ-2240 Arbitrage(Floyd)
- zoj 1092 || poj 2240 Arbitrage(Floyd)
- POJ 2240 Arbitrage(最短路 Floyd)
- POJ 2240 Arbitrage (floyd变形)
- POJ 2240 && HDU 1217 Arbitrage(Floyd)
- android NDK中对C和C++的处理不同,导致使用方法不同
- 六种方式实现hibernate查询,及IDE推荐
- hadoop安装
- CircleImageView自定义圆形控件的使用
- Java_多线程_创建和使用Java自带的线程池
- POJ 2240 Arbitrage( floyd)
- Android笔记:invalidate()和postInvalidate() 的区别及使用
- SDN与OpenFlow技术简介
- python中的urlencode与urldecode
- run as service Elasticsearch Not Working
- SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID
- 命运
- extjs4.1三个grid实现拖拽
- Hdu1251 统计难题