poj2240 floyd
//Accepted 732 KB 782 ms
//floyd应用
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
/**
* This is a documentation comment block
* 如果有一天你坚持不下去了,就想想你为什么走到这儿!
* @authr songt
*/
;
double a[imax_n][imax_n];
map<string ,int > mp;
int n;
double max(double a,double b)
{
) return b;
return a;
}
void floyd()
{
;k<=n;k++)
;i<=n;i++)
;j<=n;j++)
&& a[k][j]>1e-)
a[i][j]=max(a[i][j],a[i][k]*a[k][j]);
/*
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
printf("%.3lf ",a[i][j]);
}
printf("\n");
}
*/
}
int main()
{
;
string s;
string s1,s2;
double rate;
while (scanf("%d",&n),n)
{
mp.clear();
;i<=n;i++)
{
cin>>s;
mp[s]=i;
}
int m;
scanf("%d",&m);
;i<=n;i++)
;j<=n;j++)
{
;
;
}
;i<=m;i++)
{
cin>>s1>>rate>>s2;
//cout<<mp[s1]<<" "<<mp[s2]<<endl;
a[mp[s1]][mp[s2]]=rate;
}
floyd();
;
;i<=n;i++)
>1e-) flag=;
printf("Case %d: ",++t);
if (flag) printf("Yes\n");
else printf("No\n");
}
;
}
poj2240 floyd的更多相关文章
- POJ-2240(floyd算法简单应用)
Arbitrage poj-2240 #include<iostream> #include<cstdio> #include<cstring> #include& ...
- POJ2240 Arbitrage(Floyd判负环)
跑完Floyd后,d[u][u]就表示从u点出发可以经过所有n个点回到u点的最短路,因此只要根据数组对角线的信息就能判断是否存在负环. #include<cstdio> #include& ...
- POJ2240——Arbitrage(Floyd算法变形)
Arbitrage DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform o ...
- poj2240 - Arbitrage(汇率问题,floyd)
题目大意: 给你一个汇率图, 让你判断能否根据汇率盈利 #include <iostream> #include <cstdlib> #include <cstdio&g ...
- poj2240最短路 floyd
Arbitrage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17360 Accepted: 7308 Descri ...
- POJ-2240 Arbitrage---判断正环+枚举
题目链接: https://vjudge.net/problem/POJ-2240 题目大意: 已知n种货币,以及m种货币汇率及方式,问能否通过货币转换,使得财富增加. 思路: 由于这里问的是财富有没 ...
- floyd算法学习笔记
算法思路 路径矩阵 通过一个图的权值矩阵求出它的每两点间的最短路径矩阵.从图的带权邻接矩阵A=[a(i,j)] n×n开始,递归地进行n次更新,即由矩阵D(0)=A,按一个公式,构造出矩阵D(1):又 ...
- 最短路(Floyd)
关于最短的先记下了 Floyd算法: 1.比较精简准确的关于Floyd思想的表达:从任意节点A到任意节点B的最短路径不外乎2种可能,1是直接从A到B,2是从A经过若干个节点X到B.所以,我们假设maz ...
- 最短路径之Floyd算法
Floyd算法又称弗洛伊德算法,也叫做Floyd's algorithm,Roy–Warshall algorithm,Roy–Floyd algorithm, WFI algorithm. Floy ...
随机推荐
- top free综合监控工具
top选项: -d:指定刷新时间间隔 -n:指定刷新次数 -u:指定只显示user用户的进程信息 -p:指定只显示pid的进程信息 [root@linuxzgf ~]# top Mem: 817449 ...
- LeetCode----8. String to Integer (atoi)(Java)
package myAtoi8; /* * Implement atoi to convert a string to an integer. Hint: Carefully consider all ...
- :before\:after伪元素用法
:before和:after这两个伪元素在真正的页面元素之前和之后插入一个额外的的元素,等效于下面的代码: <p> <span>:before</span> HTM ...
- [问题2014A10] 解答
[问题2014A10] 解答 考虑如下变形: \[(I_n-A)^2=(AA'-A)(I_n-A)=A(A'-I_n)(I_n-A)=-A(I_n-A)'(I_n-A).\] 因为 \(A\) 是非 ...
- MySQL修改表一次添加多个列(字段)和索引
MySQL修改表一次添加多个列(字段) ALTER TABLE table_name ADD func varchar(50), ADD gene varchar(50), ADD genedetai ...
- Intellij 图标介绍及配置文件常识
图标 参数名称 含义 默认值 -Xms 初始堆大小 物理内存的1/64(<1GB) 默认(MinHeapFreeRatio参数可以调整)空余堆内存小于40%时,JVM就会增大堆直到-Xm ...
- RMAN的实战篇--备份脚本
案列一. 目标: 1.每天夜间1 点执行:2.数据库全备,同时备份控制文件及归档日志文件,备份文件保存至: /backup\目录下,并在完成归档日志文件备份后,自动删除已备份的归档日志:3.备份保留7 ...
- Server asks us to fall back to SIMPLE auth, but this client is configured to only allow secure connections.
我是在flume向hdfs 写(sink)数据时遇到的这个错误. Server (是指hdfs) asks us to fall back to SIMPLE auth, but this clien ...
- python3 字典相关函数
python版本3.5 #Author by Liguangbo#_*_ coding:utf-8 _*_'''info={'No.1':'ligb','No.2':'donglx','No.3':' ...
- vue学习笔记之v-if
if顾名思义就是判断,v-if也是判断,举例如下 <p v-if="hello">Hello!</p> 这里 v-if 指令将根据表达式 hello 值的真 ...