poj1860】的更多相关文章

Currency Exchange DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points sp…
题目链接: https://vjudge.net/problem/POJ-1860 题目大意: 我们的城市有几个货币兑换点.让我们假设每一个点都只能兑换专门的两种货币.可以有几个点,专门从事相同货币兑换.每个点都有自己的汇率,外汇汇率的A到B是B的数量你1A.同时各交换点有一些佣金,你要为你的交换操作的总和.在来源货币中总是收取佣金. 例如,如果你想换100美元到俄罗斯卢布兑换点,那里的汇率是29.75,而佣金是0.39,你会得到(100 - 0.39)×29.75=2963.3975卢布. 你…
Currency Exchange POJ-1860 这题其实是最短路问题的变形,但是这里不用求解最短路,而是求解路径中是否存在正圈.如果存在正圈则说明兑换后的货币可以一直增加,否则不能实现通过货币转化来增加财富. 这和经典的使用Bellman-Ford判断是否存在负权也有不同的地方,这里需要在松弛方程中,改变判断的条件. package POJ; import java.util.*; public class POJ_1860 { static int n,m,s; static doubl…
链接:http://poj.org/problem?id=1860 Currency Exchange Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currenc…
//水题-SPFA解法 //套汇是指兑换货币后能使本金上升 //给定本金货币编号,货币间的汇率和手续费,求能否套汇成功 //Time:16Ms Memory:200K #include<iostream> #include<cstring> #include<cstdio> #include<queue> using namespace std; #define MAX 105 struct Edge { int u, next; double w, c;…
题目链接:http://poj.org/problem?id=1860 题目大意:给你一些兑换方式,问你能否通过换钱来赚钱? 使用ford算法,当出现赚钱的时候就返回YES,如果不能赚钱,则返回NO 应该是可以停下来的,但是我不会分析复杂度,谁来教教我? #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <map> #inclu…
Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22123   Accepted: 7990 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and pe…
题目链接. 分析: 以前没做出来,今天看了一遍题竟然直接A了.出乎意料. 大意是这样,给定不同的金币的编号,以及他们之间的汇率.手续费,求有没有可能通过不断转换而盈利. 直接用Bellman-ford检测负环的方法检测. #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; <<); struct Node { int u, v; double r, c…
题意:这里有N种货币,分别记为1~N,有M种货币交换的方式,每一种方式有A,B两种钱币,有RAB, CAB, RBA and CBA,四个数,表示交换率, Nick手上有其中的一种货币S,货币S的钱数为V,问你能否通过一定次数的钱币交换让Nick手中的钱增加 分析: 这里是要判断回路,那么可以用spfa 加一个入队次数的数组来判别是否有回路,也可以用bellman,这里要注意的是,松弛操作不能死用模板了,, 要有一点点的转变,这里我们可以这样处理,置 d 这个松弛要用到的数组为0,不是以往的无穷…
题目连接:http://poj.org/problem?id=1860 题意:有多种从a到b的汇率,在你汇钱的过程中还需要支付手续费,那么你所得的钱是 money=(nowmoney-手续费)*rate,现在问你有v钱,从s开始出发交换钱能不能赚钱. 分析:如何存在正环,能无限增加钱,肯定可以赚了,因此用spfa判一下即可 #include <cstdio> #include <cstring> #include <string> #include <cmath&…
本题思路:每完成一次交换之后交换余额多于原钱数则存在正环,输出YES即可. 参考代码: #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; const int maxn = 5e2; struct node { int to, next; double r, c; } G[maxn]; int n, m, s, num;…
刚上来一堆英文着实有点蒙逼,仔细分析是一个Bellman的变形,只要能找出一个无限增大的环这个题就好解决了,我这里用的SPFA,用邻接链表进行储存,直接套用的模板,部分变量名字没有改的很好 #include <iostream> #include<string.h> #include <queue> #include <vector> using namespace std; #define MAX 99999999; double dis[1000+6];…
题意: 给出一张各种货币交换的网络,问在网络中交换原有的货币,问货币能否增值? 解析: 判断是否存在正环即可  用spfa  负环和正环的判定方法一样  如果一个点的进队次数超过n次 则存在环 代码如下: #include <iostream> #include <cstring> #include <cstdio> #include <queue> #include <cmath> #include <algorithm> #def…
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair o…
http://poj.org/problem?id=1860 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be sev…
1860的思路是将可以换得的不同种的货币的数量当作节点,每个兑换点当成边,然后我抄了个算法导论里面的Bellman-Ford算法,一次就过了.看discussion里面很多讨论精度的,我想都没想过…… 2240是更简单的一个bellman-ford,基本和1860一样,就只多了个map容器的应用而已. 以下是1860: #include <iostream> using namespace std; struct Point{ int a, b; double Rab, Cab, Rba, C…
Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the…
题目连接:http://poj.org/problem?id=1860 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can b…
传送门:点击打开链接 题目大意:一个城市有n种货币,m个货币交换点,你有v的钱,每个交换点只能交换两种货币,(A换B或者B换A),每一次交换都有独特的汇率和手续费,问你存不存在一种换法使原来的钱更多. 思路:一开始以为一个地方只能用一次,感觉好像有点难,后来发现自己读错题了,其实只要判断给你的这幅图存不存在正环就可以了,用dis[]表示某种货币的数量,然后bellman判断正环就可以了.(题目里强调结尾一定要原来的货币,但其实这是废话,因为是以原来的货币为起点的,所以你换出去了一定换的回来),正…
Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 24243   Accepted: 8813 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and pe…
题目链接:http://poj.org/problem?id=1860 Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 32128   Accepted: 12228 Description Several currency exchange points are working in our city. Let us suppose that each point specialize…
Bellman_ford算法用于寻找正环或者负环! 算法导论: 24.1 The Bellman-Ford algorithm The Bellman-Ford algorithm solves the single-source shortest-paths problem in the general case in which edge weights may be negative. Given a weighted, directed graph G = (V, E) with sou…
Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the…
题目链接:http://poj.org/problem?id=1860 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can b…
题意:有m个货币交换点,每个点只能有两种货币的互相交换,且要给佣金,给定一开始的货币类型和货币数量,问若干次交换后能否让钱增加. 思路:spfa求最长路,判断是否存在正环,如果存在则钱可以在环中一直增加,最后的钱肯定也是增加的. #include <iostream> #include <cstring> #include <queue> #include <cstdio> using namespace std; + ; struct edge{ int…
题目传送门 题意:有多种汇币,汇币之间可以交换,这需要手续费,当你用100A币交换B币时,A到B的汇率是29.75,手续费是0.39,那么你可以得到(100 - 0.39) * 29.75 = 2963.3975 B币. 题解:我们可以用货币种类编号建图,在图上任意两点表示兑换关系并且是双向的,值得注意的是货币A没有兑换是的权值是不变的,而A兑换成B那么B的权值就是(k-Cab)*Rab,那么我们只要Floyd跑一边.然后判断是否存在一个dis[v]>dis[i]+w; 代码: #include…
poj2965 poj1753:标准的BFS+位运算优化 poj1328:线段覆盖变种,把圆对应到线段上,贪心求解 poj2109:高精度开根,二分+高精度,注意要判断答案的位数,如果按照题目给的范围二分会TLE poj2586:给十二个月定盈亏(每个月+s或-d),连续5个月总的需要时亏,求12个月的总的最大盈利.枚举或者贪心,贪心的话就尽量把亏损的放在连续五个月的后面,这样使得-d尽可能少 poj3295:枚举所有bool变量的取值,然后带入算 poj3259:裸的spfa判断负还 poj1…
初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford…
OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632…
[转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 搜索(至少4题) (稍难,也可并查集) 第三类 贪心(至少2题) (难) 第四类 最短路 (至少3题) Bellman-Ford (难) 第五类 最小生成树 (至少2题, 而且 Prim 和 Kruskal 至少各用一次) 第六类 最大流 (至少2题) (最小费用最大流) (难) 第七类 二分图…