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 <cstdio> #include <cstring> using namespace std; int size[20]; char s[15]; char c[15]; int sum[15]; int nbus,i,j,arr; int dur[20][10]; int main() { while(scanf("%s",s)!=EOF) { if(strcmp(s,"ENDOFINPUT")==0)break; scanf("%d",&nbus); gets(s); memset(dur,0,sizeof(int)*20*10); memset(size,0,sizeof(size)); for(i=0;i<nbus;i++)//读取部分 { j=0; gets(c); for(int k=0;k<strlen(c);k++) { if(c[k]==' '||c[k]=='\n') { j++; continue; } else { dur[i][j]=dur[i][j]*10+c[k]-'0'; } } size[i]=++j; }//nbus scanf("%d",&arr); memset(sum,0,sizeof(sum)); for(i=0;i<nbus;i++) { j=0; while(sum[i]<arr) { sum[i]+=dur[i][j%size[i]]; j++; } sum[i]-=arr; } int min=sum[0]; for(i=0;i<nbus;i++) { if(sum[i]<min) min=sum[i]; } scanf("%s",s); printf("%d\n",min); }//while return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator