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. 分析: 首先我们要把货币之 ...
随机推荐
- 【sqli-labs】 less59 GET -Challenge -Double Query -5 queries allowed -Variation2 (GET型 挑战 双查询 只允许5次查询 变化2)
整型的注入 http://192.168.136.128/sqli-labs-master/Less-59/?id=1 or UpdateXml(1,concat(0x7e,database(),0x ...
- HDU_1285_拓扑排序(优先队列)
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- Replacing Threads with Dispatch Queues
Replacing Threads with Dispatch Queues To understand how you might replace threads with dispatch que ...
- id拼接保存到单个字段后作为表连接的查询条件
SELECT q.id, concat(q. NAME) qname, d.id did, d. NAME FROM question_po q LEFT JOIN data_configuratio ...
- Redis 之仿微博demo
一.用户注册登录 include './header.php'; include './function.php'; $username = p('username'); $password = p( ...
- Git学习总结二(版本回退)
修改修改仓库中readme.txt文件,然后用git status命令看看结果: $ git status On branch master Changes not staged for commit ...
- Appium使用方法说明
global driver# 元素定位driver.find_element_by_id("id") # id定位driver.find_element_by_name(" ...
- time模块和datatime模块
一.time模块 time.time() 获取时间戳 time.sleep() 睡几秒 time.gmtime() utc时间元组 time.localtime() 本地时间元组 time.mktim ...
- BOM对象和DOM对象
一.BOM对象 BOM(Browser Object Model)是指浏览器对象模型,可以对浏览器窗口进行访问和操作.使用 BOM,开发者可以移动窗口.改变状态栏中的文本以及执行其他与页面内容不直接相 ...
- Centos 7 关闭firewall防火墙启用iptables防火墙
一.关闭firewall防火墙 1.停止firewall systemctl stop firewalld.service 2.禁止firewall开机启动 systemctl disable fir ...