poj 1860 bellman 求正环】的更多相关文章

#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…
题意:给出n种货币,m中交换关系,给出两种货币汇率和手续费,求能不能通过货币间的兑换使财富增加. 用Bellman_Ford 求出是否有正环,如果有的话就可以无限水松弛,财富可以无限增加. #include<string.h> #include<stdio.h> const int N=110; const int inf=0x3fffffff; int start,num,n; double dist[N],wf; struct edge { int st,ed; double…
心累,陕西邀请赛学校不支持,可能要自费了.. 思路:套用Bellman-Ford判断负环的思路,把大于改成小于即可判定是否存在从源点能到达的正环.如果存在正环,那么完全多跑几次正环就可以把钱增加到足够返回到S并且大于原来的金额. AC代码 #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <cstring> #include <…
//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=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…
传送门:点击打开链接 题目大意:一个城市有n种货币,m个货币交换点,你有v的钱,每个交换点只能交换两种货币,(A换B或者B换A),每一次交换都有独特的汇率和手续费,问你存不存在一种换法使原来的钱更多. 思路:一开始以为一个地方只能用一次,感觉好像有点难,后来发现自己读错题了,其实只要判断给你的这幅图存不存在正环就可以了,用dis[]表示某种货币的数量,然后bellman判断正环就可以了.(题目里强调结尾一定要原来的货币,但其实这是废话,因为是以原来的货币为起点的,所以你换出去了一定换的回来),正…
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…
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…
题意:给出n个房间,初始在房间1有100的能量值,每次进入一个房间,能量值可能增加也可能减小,(是点权,不是边权),问能否到达终点的时候能量值还为正 这题自己写的时候wa--wa-- 后来看了题解,还是wa---wa--- 题解很详细http://blog.csdn.net/freezhanacmore/article/details/9937327 记录下自己犯的错误吧 首先是floyd函数初始化的时候,直接写在了函数里面,这样是不对的,因为输入值在前,调用函数在后,这样就相当于将之前输入的可…
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…