题意:给出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 cost,w;
}e[220];
void addedge(int x,int y,double w,double c)
{
e[num].st=x;e[num].ed=y;e[num].cost=c;e[num++].w=w;
}
int Bellman_Ford()
{
int flag=0,i,u......
阅读全文