| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大牛 帮忙看看 或者给个测试数据也行 谢谢#include<stdio.h>
#include<string.h>
int main()
{
char str[35][100],a[100],b[100];
int n,i,j,k,flag,m,x,y,count=0;
double map[35][35],rates;
while(scanf("%d",&n)!=EOF)
{
if(n==0)break;
count++;
memset(map,0.0,sizeof(map));
for(i=0;i<n;i++)
{
scanf("%s",str[i]);
map[i][i]=1.0;
}
scanf("%d",&m);
while(m--)
{
scanf("%s %lf %s",&a,&rates,&b);
for(i=0;i<n;i++)
{
if(strcmp(str[i],a)==0)
{
x=i;
}
else if(strcmp(str[i],b)==0)
{
y=i;
//break;
}
}
map[x][y]=rates;
}
for(k=0;k<n;k++)
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(map[i][k]*map[k][j]>map[i][j])
map[i][j]=map[i][k]*map[k][j];
flag=0;
for(i=0;i<n;i++)
{
if(map[i][i]>1.0)
{
flag=1;
break;
}
}
printf("Case %d: ",count);
if(flag==1)
printf("Yes");
else
printf("No");
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator