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. C# WebKitBrowser 设置内容

    WebKit.WebKitBrowser kitBrowser = new WebKit.WebKitBrowser(); kitBrowser.Dock = DockStyle.Fill; // k ...

  2. centos设置ssh安全只允许用户从指定的IP登陆

    1.编辑文件 /etc/ssh/sshd_config vi /etc/ssh/sshd_config 2.root用户只允许在如下ip登录 AllowUsers root@203.212.4.117 ...

  3. vue学习笔记(六)— 关于Vuex可以这样简单理解

    关于Vuex可以这样简单理解 作者:狐狸家的鱼 本文链接:关于Vuex GitHub:sueRimn 概念理解 和大多数文章都一样,从概念解释到引出问题再举例解决问题. 官网中,Vuex是状态管理模式 ...

  4. js里的深度克隆

    ES6 数组克隆 let arr = [1,2,3,4,5]; let arr1 = [...a]; arr1 = ["a","b","c" ...

  5. Luogu 2951 捉迷藏Hide and Seek

    P2951 [USACO09OPEN]捉迷藏Hide and Seek 题目描述 Bessie is playing hide and seek (a game in which a number o ...

  6. 44.bucket filter:统计各品牌最近一个月的平均价格

    课程大纲     GET /tvs/sales/_search { "size": 0, "query": { "term": { &quo ...

  7. 【Codeforces 467C】George and Job

    [链接] 我是链接,点我呀:) [题意] 让你从1..n这n个数字中 选出来k个不相交的长度为m的区间 然后这个k个区间的和最大 求出这k个区间的和的最大值 [题解] 设dp[i][j]表示前i个数字 ...

  8. 【Codeforces 126B】Password

    [链接] 我是链接,点我呀:) [题意] 给你一个字符串s 让你从中选出来一个字符串t 这个字符串t是s的前缀和后缀 且在除了前缀和后缀之外的中间部位出现过. 且要求t的长度最长. 让你输出这个字符串 ...

  9. 【codeforces 801C】Voltage Keepsake

    [题目链接]:http://codeforces.com/contest/801/problem/C [题意] 有n个设备 你想同时使用 第i个设备每分钟消耗ai点电量,一开始有bi点电量 你有一个充 ...

  10. 清北学堂模拟赛d7t1 消失的数字

    题目描述 现在,我的手上有 n 个数字,分别是 a1; a2; a3; :::; an.我现在需要删除其中的 k 个数字.当然我不希望随随便便删除,我希望删除 k个数字之后,剩下的 n - k 个数中 ...