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

Re:WHY I got WA?

Posted by pb128 at 2005-07-19 23:45:19 on Problem 2472
In Reply To:Re:WHY I got WA? Posted by:shouhm at 2005-07-10 14:11:32
#include<stdio.h>
int v[100];
float f(float p[][100],int n,int v1,int v2)
{float max=p[v1][v2],t=0;
 int i,j;
 v[v1]=1;
 for(j=0;j<n;j++)
 if(j!=v2&&v[j]==0&&p[v1][j]>max)t=p[v1][j]*f(p,n,j,v2);
 if(t>max)max=t;
 v[v1]=0;
 return max;
}


int main()
{int i=0,k,l,j,n[50],m,a,b;
 float p[10][100][100]={0},t;
 while(scanf("%d",&n[i])&&n[i]!=0)
 {
	scanf("%d",&m);
	for(j=0;j<m;j++)
	{
	 scanf("%d%d",&a,&b);
	 scanf("%f",&t);
	 p[i][a-1][b-1]=p[i][b-1][a-1]=t/100.0;
	}
  i++;
 }
 for(j=0;j<i;j++)
 {for(k=0;k<n[j];k++)v[k]=0;
 //for(k=0;k<n[j];k++)
 //{for(l=0;l<n[j];l++)printf("%f\t",p[j][k][l]);printf("\n");}
  printf("%f\n",100*f(p[j],n[j],0,n[j]-1));
}
}

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