题目链接: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…
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…
转载来源:優YoU  http://user.qzone.qq.com/289065406/blog/1299337940 提示:关键在于反向利用Bellman-Ford算法 题目大意 有多种汇币,汇币之间可以交换,这需要手续费,当你用100A币交换B币时,A到B的汇率是29.75,手续费是0.39,那么你可以得到(100 - 0.39) * 29.75 = 2963.3975 B币.问s币的金额经过交换最终得到的s币金额数能否增加 货币的交换是可以重复多次的,所以我们需要找出是否存在正权回路,…
题意:有m个货币交换点,每个点只能有两种货币的互相交换,且要给佣金,给定一开始的货币类型和货币数量,问若干次交换后能否让钱增加. 思路:spfa求最长路,判断是否存在正环,如果存在则钱可以在环中一直增加,最后的钱肯定也是增加的. #include <iostream> #include <cstring> #include <queue> #include <cstdio> using namespace std; + ; struct edge{ int…
Currency Exchange POJ - 1860 题意: 有许多货币兑换点,每个兑换点仅支持两种货币的兑换,兑换有相应的汇率和手续费.你有s这个货币 V 个,问是否能通过合理地兑换货币,使得你手中的货币折合成s后是有增加的. 思路: 这道题在建立每种货币的兑换关系后,找到图中的正环即可,因为你沿着正环跑就可以增加价值.这里可以用类似Bellman_Ford判断负环的方法. #include <algorithm> #include <iterator> #include &…
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…
//spfa 判断正环 #include<iostream> #include<queue> #include<cstring> using namespace std; const int N=1e4; const int INF=2e9; int h[N],to[N],ne[N],idx; double r[N],c[N]; int n, m,X; double V; void add(int u,int v,double r1,double c1) { to[id…
题目链接:http://poj.org/problem?id=3621 Sightseeing Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11526   Accepted: 3930 Description Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big ci…
Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big city! The cows must decide how best to spend their free time. Fortunately, they have a detailed city map showing the L (2 ≤ L ≤ 1000) major landmarks (…
Currency Exchange Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1860 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two par…
题目链接: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…
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…
题目连接:http://poj.org/problem?id=1860 题意:有多种从a到b的汇率,在你汇钱的过程中还需要支付手续费,那么你所得的钱是 money=(nowmoney-手续费)*rate,现在问你有v钱,从s开始出发交换钱能不能赚钱. 分析:如何存在正环,能无限增加钱,肯定可以赚了,因此用spfa判一下即可 #include <cstdio> #include <cstring> #include <string> #include <cmath&…
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…
d[i]代表从起点出发可以获得最多的钱数,松弛是d[v]=r*d[u],求最长路,看有没有正环 然后这题输入有毒,千万别用cin 因为是大输入,组数比较多,然后找字符串用strcmp就好,千万不要用map 这题刚开始我T了(用的map),还以为组数很多卡spfa呢,然后我上网看了看都是floyd的,然后我用floyd写了一发,891ms过了 然后我感觉spfa的复杂度也不是很大,就是看有没有正环,所以我觉得可能是map+cin的锅,然后改了一发,用的spfa,47ms过 真是,算了,实质是本蒟蒻…
原题链接:http://poj.org/problem?id=1860 Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 23055   Accepted: 8328 Description Several currency exchange points are working in our city. Let us suppose that each point specializes…
链接: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…
题目链接:http://poj.org/problem?id=1860 题意是给你n种货币,下面m种交换的方式,拥有第s种货币V元.问你最后经过任意转换可不可能有升值.下面给你货币u和货币v,r1是u到v的汇率,c1是u到v的手续费,同理r2是v到u的汇率,c2是v到u的手续费.转换后的钱B = (转换之前的钱A - c) * r. 我用spfa做的,不断地松弛.要是存在正环,或者中间过程最初的钱升值了,就说明会升值.有负环的话,不满足松弛的条件,慢慢地就会弹出队列,也就不会升值. #inclu…
XYZZY Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4421    Accepted Submission(s): 1252 Problem Description It has recently been discovered how to run open-source software on the Y-Crate gami…
XYZZY Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5304    Accepted Submission(s): 1510 Problem Description It has recently been discovered how to run open-source software on the Y-Crate gam…
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=3259 Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 55082   Accepted: 20543 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is ver…
#include<stdio.h> #include<string.h> #include<queue>//只需判断是否有正环路径就可以了 using namespace std; #define N  200 struct node { double r,c; }map[N][N]; double maxvalue[N],h; int n,cou[N]; int  bellmanford(int start) {   queue<int>q;   int…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25957 思路:由于路线为一个环,将路径上的权值改为c-p*d,那么然后建图,那么我们只需判断图中是否存在权值和为正的环,这个用spfa即可. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue&g…
题目链接. 分析: 以前没做出来,今天看了一遍题竟然直接A了.出乎意料. 大意是这样,给定不同的金币的编号,以及他们之间的汇率.手续费,求有没有可能通过不断转换而盈利. 直接用Bellman-ford检测负环的方法检测. #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; <<); struct Node { int u, v; double r, c…
题目链接:http://poj.org/problem?id=1860 题目大意:给你一些兑换方式,问你能否通过换钱来赚钱? 使用ford算法,当出现赚钱的时候就返回YES,如果不能赚钱,则返回NO 应该是可以停下来的,但是我不会分析复杂度,谁来教教我? #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <map> #inclu…
http://poj.org/problem?id=1860 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 29874   Accepted: 11251 题目大意: ´有多种汇币,汇币之间可以交换,这需要手续费,当你用100A币交换B币时,A到B的汇率是29.75,手续费是0.39,那么你可以得到(100 - 0.39) * 29.75 = 2963.3975 B币.问s币的金额经过交换最终得到的s币金额数能否增加.…
http://poj.org/problem?id=3621 Sightseeing Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7649   Accepted: 2567 Description Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big city! Th…
Currency Exchange Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 60000/30000K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 2 Problem Description Several currency exchange points are working in our city. Let us suppose that…
题意:给出n个房间,初始在房间1有100的能量值,每次进入一个房间,能量值可能增加也可能减小,(是点权,不是边权),问能否到达终点的时候能量值还为正 这题自己写的时候wa--wa-- 后来看了题解,还是wa---wa--- 题解很详细http://blog.csdn.net/freezhanacmore/article/details/9937327 记录下自己犯的错误吧 首先是floyd函数初始化的时候,直接写在了函数里面,这样是不对的,因为输入值在前,调用函数在后,这样就相当于将之前输入的可…