求大佬指出为什么会Compile Error(哭
  • 板块P1576 最小花费
  • 楼主FdogJ
  • 当前回复11
  • 已保存回复11
  • 发布时间2022/12/19 22:48
  • 上次更新2023/11/26 16:25:30
查看原帖
求大佬指出为什么会Compile Error(哭
820929
FdogJ楼主2022/12/19 22:48
#define _USE_MINGW_ANSI_STDIO 1
# include <bits/stdc++.h>
using namespace std;
double dis[100005];
double discount[100005][100005];
long  mark[100005]={0};
int n,m;
int x,y,z;
int A,B;
int maxn,temp;
int main()
{
	cin>>n;
	cin>>m;
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		cin>>discount[x][y];
		discount[x][y]=(100-discount[x][y])/100;
		discount[y][x]=discount[x][y];//记录扣除 
	}
	cin>>A>>B;//以上为读入数据
	for (int i=1;i<=n;i++)
	{
		dis[i]=discount[A][i];
	}
	dis[A]=1;//自己定为1好做接下来的操作
	mark[A]=1;
	for (int i=1;i<=n-1;i++)
	{
		maxn=0;
		for (int j=1;j<=n;j++)
		{
			if (mark[j]==0 && dis[j]>maxn)
			{
				temp=j;
				maxn=dis[j];
			}
		}
		mark[temp]=1;
		if (temp==B)break;
		for (int k=1;k<=n;k++)//Dijkstra算法 
		{
			if (mark[k]==0 && dis[temp]*discount[temp][k]>dis[k])
			{
				dis[k]=dis[temp]*discount[temp][k];	
			}
		}
	}
	printf("%0.8lf\n",100/dis[B]);
	return 0; 
}
2022/12/19 22:48
加载中...