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<stdio.h> #include<math.h> #include<string.h> int main(void) { int a[25][20],d[25],q,n,i,j,k,m,flag,min; char b[50],c[50]; while(scanf("%s",&b)!=EOF&&strcmp(b,"ENDOFINPUT")) //读“START” { scanf("%d",&n); //读n for(i=0;i<n;i++) //读n行数据 { q=0; for(j=0;;j++) { scanf("%d",&a[i][j]); q++; if(getchar()=='\n')break; } d[i]=q; //统计每行有m个数,把m存入d[i] } scanf("%d",&m); //读入等待时间 scanf("%s",&c); //读“END“ if(m==0) //若等待时间为0,则无需等待 { printf("0\n"); continue; } for(i=0;i<n;i++) //计算每行(每条路线)需要等待时间 { k=m; while(1) { flag=0; for(j=0;j<d[i];j++) //不断减每条路线每个站的持续时间,直到 k<a[i][j] { if(k>=a[i][j]) k-=a[i][j]; else { flag=1; break; } } if(flag==1) break; } if(k==0) //把等待时间存入d[i] d[i]=0; else d[i]=a[i][j]-k; } min=d[0]; for(i=0;i<n;i++) //找出每条路线最小的等待时间 { if(min>d[i]) min=d[i]; } printf("%d\n",min); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator