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> int num[30],gn[10][30],f[30]; int main() { int i,j,g,n,k,min,left; while (scanf ("%d%d",&g,&n)!=EOF&&g&&n) { for (i=0;i<g;i++) for (j=0;j<=n;j++) scanf ("%d",&gn[i][j]); for (i=0;i<30;i++) f[i]=0; left=n-1; while (left) { for (i=0;i<30;i++) num[i]=-1; for (i=0;i<g;i++) { for (j=1;j<=n;j++) if (f[gn[i][j]]==0) { num[gn[i][j]]+=gn[i][0]; break; } } k=-1; min=1000000000; for (i=1;i<=n;i++) if (f[i]==0) if (min>=num[i]) { min=num[i]; k=i; } left--; f[k]=1; } k=0; for (i=1;i<=n;i++) if (f[i]==0) { k=i; break; } printf ("%d\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