poj 2240 Arbitrage】的更多相关文章

题目传送门 /* 最短路:Floyd模板题 只要把+改为*就ok了,热闹后判断d[i][i]是否大于1 文件输入的ONLINE_JUDGE少写了个_,WA了N遍:) */ #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <string> #include <map> #include <cmath>…
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For exa…
Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21300   Accepted: 9079 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currenc…
链接:poj 2240 题意:首先给出N中货币,然后给出了这N种货币之间的兑换的兑换率. 如 USDollar 0.5 BritishPound 表示 :1 USDollar兑换成0.5 BritishPound. 问在这N种货币中是否存在货币经过若干次兑换后,兑换成原来的货币能够使货币量添加. 思路:本题事实上是Floyd的变形.将变换率作为构成图的路径的权值.只是构成的图是一个有向图. 最后将松弛操作变换为:if(dis[i][j]<dis[i][k]*dis[k][j]). #includ…
链接: http://poj.org/problem?id=2240 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#problem/F Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13067   Accepted: 5493 Description Arbitrage is the use of discrepancies i…
http://poj.org/problem?id=2240 题意 : 好吧,又是一个换钱的题:套利是利用货币汇率的差异进行的货币转换,例如用1美元购买0.5英镑,1英镑可以购买10法郎,一法郎可以购买0.21美元,所以0.5*10*0.21 = 1.05,从中获利百分之五,所以需要编写一个程序,在进行完转换之后能不能获利,如果能就输出Yes,反之No: 样例解释 : 3 USDollar BritishPound FrenchFranc 6 USDollar 0.5 BritishPound…
题目:http://poj.org/problem?id=2240 题意:给定n个货币名称,给m个货币之间的汇率,求会不会增加 和1860差不多,求有没有正环 刚开始没对,不知道为什么用 double往结构体里传值的时候 会去掉小数点后的 数 #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<qu…
http://poj.org/problem?id=2240 题意:货币兑换,判断最否是否能获利. 思路:又是货币兑换题,Belloman-ford和floyd算法都可以的. #include<iostream> #include<algorithm> #include<string> #include<cstring> #include<map> using namespace std; + ; int n, m; string s1,s2;…
题目链接:http://poj.org/problem?id=2240 题目就是要通过还钱涨自己的本钱最后还能换回到自己原来的钱种. 就是判一下有没有负环那么就直接用bellman_ford来判断有没有负环 #include <iostream> #include <cstring> #include <string> using namespace std; int n , m , s , a , b , counts; double rx , ry , cx , c…
Time Limit: 1000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency in…
点击打开链接 Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13434   Accepted: 5657 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same…
Arbitrage 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/I Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose…
题意  给你n种币种之间的汇率关系  推断是否能形成套汇现象  即某币种多次换为其他币种再换回来结果比原来多 基础的最短路  仅仅是加号换为了乘号 #include<cstdio> #include<cstring> #include<string> #include<map> using namespace std; map<string, int> na; const int N = 31; double d[N], rate[N][N],…
Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 Fre…
Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:27167   Accepted: 11440 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currenc…
Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 Fre…
Time Limit: 1000MS Memory Limit: 65536K Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 Brit…
Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13800   Accepted: 5815 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currenc…
Arbitrage Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 Frenc…
题意: 给出一些货币和货币之间的兑换比率,问是否可以使某种货币经过一些列兑换之后,货币值增加. 举例说就是1美元经过一些兑换之后,超过1美元.可以输出Yes,否则输出No. 分析: 首先我们要把货币之间的关系转化成一张图.转化时,用STL里面的map很方便. 为每种货币分配一个序列号,一个序列号代表了一个图中间的NODE,而node之间的edge用汇率表示. 一开始用Dijkstra算法做,死活AC不了,网友给的理由是: 由于Dijkstra算法不能处理带有负权值的最短路,但此题中,两种货币之间…
d[i]代表从起点出发可以获得最多的钱数,松弛是d[v]=r*d[u],求最长路,看有没有正环 然后这题输入有毒,千万别用cin 因为是大输入,组数比较多,然后找字符串用strcmp就好,千万不要用map 这题刚开始我T了(用的map),还以为组数很多卡spfa呢,然后我上网看了看都是floyd的,然后我用floyd写了一发,891ms过了 然后我感觉spfa的复杂度也不是很大,就是看有没有正环,所以我觉得可能是map+cin的锅,然后改了一发,用的spfa,47ms过 真是,算了,实质是本蒟蒻…
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<string> #include<vector> #include<queue> using namespace std; ; int n,m; double Vcur[MAXN],R[MAX…
和POJ1860差不多,就是用bellmanford判读是否存在正环,注意的是同种货币之间也可以交换,就是说:A货币换A货币汇率是2的情况也是存在的. #include<stdio.h> #include<string.h> #include<cstring> #include<string> #include<math.h> #include<queue> #include<algorithm> #include<…
https://vjudge.net/problem/POJ-2240 题意 已知n种货币,以及m种货币汇率及方式,问能否通过货币转换,使得财富增加. 分析 Bellman-Ford判断正环,注意初始化时置为0. #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<vector> #inc…
题意:给出n种货币,m种兑换比率(一种货币兑换为另一种货币的比率),判断测试用例中套汇是否可行.(套汇的意思就是在经过一系列的货币兑换之后,是否可以获利.例如:货币i→货币j→货币i,这样兑换后,是否可以获利,即比率是否>1).举个例子理解套汇:假设,1美元买10人民币(比率为10),10人民币买100美元(比率为10).这就是套汇,总比率=10*10=100,100>1,所以可以获利. 思路:Floyed-Warshall算法,枚举所有的货币之间的兑换比率,最后若存在一种回路且回路比率>…
三道题都是考察最短路算法的判环.其中1860和2240判断正环,3259判断负环. 难度都不大,可以使用Bellman-ford算法,或者SPFA算法.也有用弗洛伊德算法的,笔者还不会SF-_-…… 直接贴代码. 1860 Currency Exchange: #include <cstdio> #include <cstring> int N,M,S; double V; ; int first[maxn],vv[maxn*maxn],nxt[maxn*maxn]; double…
http://poj.org/problem?id=2240 用log化乘法为加法找正圈 c++ 110ms,g++tle #include <string> #include <map> #include <iostream> #include <cmath> #include <cstring> #include <queue> using namespace std; const int maxn = 50; bool vis[…
题目链接:http://poj.org/problem?id=2240 题意:n种国家的货币,m个换算汇率.问你能不能赚钱. eg:1美元换0.5英镑,1英镑换10法郎,1法郎换0.21美元,这样1美元能换0.5*10*0.21=1.05美元,净赚0.05美元.   题解:floyd跑的时候改成乘法运算.然后就是在货币上做一个map的映射. 代码: #include <iostream> #include <string> #include <map> #include…
  Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17374   Accepted: 7312 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For e…
题目链接:https://vjudge.net/problem/POJ-2240 思路:判正环,Bellman-ford和SPFA,floyd都可以,有正环就可以套利. 这里用SPFA,就是个板子题吧,把松弛改成乘法操作就好了. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <st…