Arbitrage(floyd)
http://poj.org/problem?id=2240
#include <stdio.h>
#include <string.h>
const int INF=<<;
double dis[][];
char str[][];
int n,m; void init()
{
for (int i = ; i <= n; i ++)
{
for (int j = ; j <= n; j ++)
{
dis[i][j] = ;
}
}
}
int Deal(char *s)
{
for (int i = ; i <= n; i ++)
{
if (!strcmp(s,str[i]))
return i;
}
return ;
}
void floyd()
{
for (int k = ; k <= n; k ++)
{
for (int i = ; i <= n; i ++)
{
for (int j = ; j <= n; j ++)
{
if (dis[i][j] < dis[i][k]*dis[k][j])
dis[i][j] = dis[i][k]*dis[k][j];
}
}
} }
int main()
{
int o = ;
while(~scanf("%d%*c",&n)&&n)
{
++o;
char ss[],ss1[];
double rate;
init();
for (int i = ; i <= n; i ++)
{
scanf("%s",str[i]);
}
scanf("%d%*c",&m);
while(m--)
{
scanf("%s",ss);
int i = Deal(ss);
scanf("%lf",&rate);
scanf("%s",ss1);
int j = Deal(ss1);
dis[i][j] = rate;
}
floyd();
int flag = ;
for (int i = ; i <= n; i ++)
{
if (dis[i][i] > )
flag = ;
}
if (flag)
printf("Case %d: Yes\n",o);
else
printf("Case %d: No\n",o);
}
return ;
}
Arbitrage(floyd)的更多相关文章
- HDU 1217 Arbitrage (Floyd)
Arbitrage http://acm.hdu.edu.cn/showproblem.php?pid=1217 Problem Description Arbitrage is the use of ...
- POJ2240——Arbitrage(Floyd算法变形)
Arbitrage DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform o ...
- Nyoj Arbitrage(Floyd or spfa or Bellman-Ford)
描述Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a curren ...
- hdu 1217 Arbitrage (最小生成树)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1217 /************************************************* ...
- UVa 104 - Arbitrage(Floyd动态规划)
题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...
- HDOJ 1217 Arbitrage(拟最短路,floyd算法)
Arbitrage Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- UVA 436 - Arbitrage (II)(floyd)
UVA 436 - Arbitrage (II) 题目链接 题意:给定一些国家货币的汇率.问是否能通过不断换货币使钱得到增长 思路:floyd,完事后推断一下有没有连到自己能大于1的情况 代码: #i ...
- uva 104 Arbitrage (DP + floyd)
uva 104 Arbitrage Description Download as PDF Background The use of computers in the finance industr ...
- POJ 2240 - Arbitrage(bellman_ford & floyd)
题意: 给出一些货币和货币之间的兑换比率,问是否可以使某种货币经过一些列兑换之后,货币值增加. 举例说就是1美元经过一些兑换之后,超过1美元.可以输出Yes,否则输出No. 分析: 首先我们要把货币之 ...
随机推荐
- MaskRCNN路标:TensorFlow版本用于抠图
MaskRCNN用于检测路标,作为更详细的目标检测,用以得到更精准的额路标位置,路标的几何中心点,用于构建更为精准的拓扑地图,减少构图误差. 抠图工具已经完成,把框抠出来,用0值表示背景. pytho ...
- C# Tuple 创建一个新二元集合
List<string> list1=new List<string>(); List<string> list2=new List<string>() ...
- privot函数使用
语法: table_source PIVOT( 聚合函数(value_column) FOR pivot_column IN(<column_list>) ) 将列转化为行 写个小示例 : ...
- 《啊哈算法》中P81解救小哈
题目描述 首先我们用一个二维数组来存储这个迷宫,刚开始的时候,小哼处于迷宫的入口处(1,1),小哈在(p,q).其实这道题的的本质就在于找从(1,1)到(p,q)的最短路径. 此时摆在小哼面前的路有两 ...
- gitlab分享项目到其它组
1. 找到以下页面(管理员权限),随便点入一个项目 2. 点击edit编辑 3.点击members 4. 查看是否分享成功
- web开发如何使用百度地图API(一)判断点是否在范围内
准备工作 注册开发者 创建应用 拿到百度地图ak 前端实现方案 引入百度地图API和工具类库 <script type="text/javascript" src=" ...
- Vue2构建项目实战
转载整理自http://blog.csdn.net/fungleo/article/details/77575077 vue构建单页应用原理 SPA 不是指水疗.是 single page web a ...
- POJ 3252 Round Numbers 组合数学
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13381 Accepted: 5208 Description The ...
- [bzoj2654]tree_二分_kruskal
tree bzoj-2654 题目大意:给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树.题目保证有解. 注释:$1\le V\le 5\cdot 10^4 ...
- imu 和 private redo
在传统的undo管理模式中,Oracle对undo和data block是一视同仁.这样大致会有三种弊端: 1)事务开始时,存放事务表的段头不在内存,server process需要将此i/o上来 2 ...