Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

AC (/≧▽≦)/(忘记删掉调试信息WA了无数次o(╥﹏╥)o)

Posted by 1243295518 at 2019-02-28 00:03:08 on Problem 2472
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<math.h>
#include<vector>
#include<queue>
#include<stack>
#define inf 99999999
using namespace std;
int n,m,a,b,c,cnt;
double d[110];
struct edge
{
	int a,b;
	double p;
}e[11000];
void adde(int a,int b,double p)
{
	e[cnt].a=a;
	e[cnt].b=b;
	e[cnt++].p=p;
}
int main()
{
	while(cin>>n)//n点m边 
	{
		if(!n)return 0;
		cin>>m;
		cnt=1;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d%d",&a,&b,&c);
		    adde(a,b,c/100.0);
	    	adde(b,a,c/100.0);
		}
	memset(d,0,sizeof(d)); 
	d[1]=1;
	for(int i=1;i<n;i++)
	for(int j=1;j<cnt;j++)
	d[e[j].b]=max(d[e[j].b],d[e[j].a]*e[j].p);
    printf("%.6f percent\n",d[n]*100);
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator