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)的更多相关文章

  1. HDU 1217 Arbitrage (Floyd)

    Arbitrage http://acm.hdu.edu.cn/showproblem.php?pid=1217 Problem Description Arbitrage is the use of ...

  2. POJ2240——Arbitrage(Floyd算法变形)

    Arbitrage DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform o ...

  3. 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 ...

  4. hdu 1217 Arbitrage (最小生成树)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1217 /************************************************* ...

  5. UVa 104 - Arbitrage(Floyd动态规划)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  6. HDOJ 1217 Arbitrage(拟最短路,floyd算法)

    Arbitrage Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  7. UVA 436 - Arbitrage (II)(floyd)

    UVA 436 - Arbitrage (II) 题目链接 题意:给定一些国家货币的汇率.问是否能通过不断换货币使钱得到增长 思路:floyd,完事后推断一下有没有连到自己能大于1的情况 代码: #i ...

  8. uva 104 Arbitrage (DP + floyd)

    uva 104 Arbitrage Description Download as PDF Background The use of computers in the finance industr ...

  9. POJ 2240 - Arbitrage(bellman_ford & floyd)

    题意: 给出一些货币和货币之间的兑换比率,问是否可以使某种货币经过一些列兑换之后,货币值增加. 举例说就是1美元经过一些兑换之后,超过1美元.可以输出Yes,否则输出No. 分析: 首先我们要把货币之 ...

随机推荐

  1. 011--c数组--排序--组成最大数

    数组--排序--组成最大数   组成最大数   任意输入一个自然数,输出该自然数的各位数字组成的最大数.例如,输入 1593 ,则输出为 9531 . 输入: 自然数 n 输出: 各位数字组成的最大数 ...

  2. ABP生成错误:必须添加对程序集“netstandard”的引用

    当前使用ABP版本为:4.6.0 升级vs2017到15.4版本,升级framework到4.7版本 如果Core版本请升级到net core 2

  3. BZOJ 1941: [Sdoi2010]Hide and Seek KDtree + 估价函数

    Code: #include<bits/stdc++.h> #define maxn 200000 #define inf 1000000000 using namespace std; ...

  4. selenium之浏览器驱动

    selenium需要配合浏览器的驱动使用,几个主要的浏览器驱动如下 浏览器 链接 Chrome https://sites.google.com/a/chromium.org/chromedriver ...

  5. 计蒜客 劫富济贫 (Trie树)

    链接 : Here! 思路 : Trie树裸题, 由开始给出的名字建一棵字典树, 然后每次查询一下抢♂劫的人名是否在字典树中, 复杂度也不清楚是多少, 反正是没给出 $M$ 的范围, 开始时用 $ha ...

  6. 洛谷——P2814 家谱

    P2814 家谱 题目背景 现代的人对于本家族血统越来越感兴趣. 题目描述 给出充足的父子关系,请你编写程序找到某个人的最早的祖先. 输入输出格式 输入格式: 输入由多行组成,首先是一系列有关父子关系 ...

  7. Python - 模块(一)

    目录 Python - 模块(一) 模块的引用方式 常用模块 random(随机模块) os模块 sys 序列化模块 hashlib subprocess optparse struct Python ...

  8. 腾讯云,搭建nginx静态网站服务器

    搭建Http静态服务器环境 任务时间:15min ~ 30min 搭建静态网站,首先需要部署环境.下面的步骤,将告诉大家如何在服务器上通过 Nginx 部署 HTTP 静态服务. 安装 Nginx 在 ...

  9. Bitvise ssh client+ chrome +SwitchyOmega *** (xjl456852原创)

    首先这个比ss还要简单,ss还需要在vps上搭建服务器.这个不需要. 但是无论是ss 还是 bitvise 都需要有一个自己的vps才行. 首先打开Bitvise ssh client程序:     ...

  10. datetime库 日期与时间

    datetime是一个关于时间的库,主要包含的类有: date    日期对象,常用的属性有year,month,day time 时间对象,hour,minute,second,毫秒 datetim ...