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 |
Re:各位大哥哥,大姐姐,帮忙看看吧!!!!In Reply To:各位大哥哥,大姐姐,帮忙看看吧!!!! Posted by:0394 at 2010-08-23 21:39:20 为什么wa啊??? > #include <iostream> > #include <stdio.h> > #include <string.h> > using namespace std; > > char ch[31][20]; > double moneoy[31]; > int n,m; > typedef struct > { > double r; > int x,y; > }node; > node e[1000]; > > int serv(char s[20]) > { > int i; > for(i=1;i<=n;i++) > if(strcmp(ch[i],s)==0) > return i; > } > > int bellman() > { > int i,k; > for(i=1;i<=n;i++) > moneoy[i]=1; > for(k=1;k<n;k++); > { > for(i=0;i<m;i++) > if(moneoy[e[i].y]<moneoy[e[i].x]*e[i].r) > moneoy[e[i].y]=moneoy[e[i].x]*e[i].r; > } > for(i=0;i<m;i++) > if(moneoy[e[i].y]<moneoy[e[i].x]*e[i].r) > return 1; > return 0; > } > int main() > { > int i,k=1,flag; > double rat; > char a[20],b[20]; > while(scanf("%d",&n)!=EOF&&n) > { > for(i=1;i<=n;i++) > scanf("%s",ch[i]); > scanf("%d",&m); > for(i=0;i<m;i++) > { > scanf("%s%lf%s",a,&rat,b); > e[i].x=serv(a); > e[i].y=serv(b); > e[i].r=rat; > } > flag=bellman(); > if(flag) > printf("Case %d: Yes\n",k++); > else > printf("Case %d: No\n",k++); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator