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 |
大牛们帮看看代码...为什么wa#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=1000; double dis[maxn]; double p[maxn][maxn]; char m[maxn][100]; char a[maxn]; char b[maxn]; int n,n1; double x; int flag; void bell(int v) { flag=0; int i,j,k; memset(dis,0,sizeof(dis)); for(i=0;i<n;i++) { dis[i]=p[v][i]; } if( dis[v]>1.0+1e-8) { flag=1; } else { for(i=2;i<n;i++) { for(k=0;k<n;k++) { for(j=0;j<n;j++) { if(dis[j]*p[j][k]>dis[k]) dis[k]=dis[j]*p[j][k]; } } } } if(dis[v]>1.0+1e-8) flag=1; } int main() { int i,j,k; int caseno=1; while(scanf("%d",&n)!=EOF) { if(n==0) break; for(i=0;i<n;i++) { scanf("%s",m[i]); } memset(p,0,sizeof(p)); scanf("%d",&n1); for(i=0;i<n1;i++) { scanf("%s %lf %s",a,&x,b); for(j=0;strcmp(a,m[j]);j++); for(k=0;strcmp(b,m[k]);k++); p[j][k]=x; } flag=0; for(i=0;i<n;i++) { bell(i); if(flag==1) { // printf("%d\n",i); break; } } if(flag==1) printf("Case %d: Yes\n",caseno++); else printf("Case %d: No\n",caseno++); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator