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 |
加了几个注释In Reply To:这个我怎么写的那么恶心,而且慢,怎么优化一下呢? Posted by:sunmoonstar_love at 2005-08-05 22:16:42 > #include <stdio.h> > int n,p,i,j,simp[101],rating[101],min,max; // rating[] 表示复杂度 > bool sim[101],exist; // simp[]表示被当作最简单的次数 > //sim[]记录是否为要输出的题号 > int main() > { > scanf("%d%d",&n,&p); > for(i=1; i<=p; i++) > { > sim[i] = true; > simp[i] = 0; > } > for(i=0; i<n; i++) > { > for(j=1; j<=p; j++) > scanf("%d",&rating[j]); > min = 1001; > max = -1; > for(j=1; j<=p; j++) > { > if(rating[j]<min) > min = rating[j]; > if(rating[j]>max) > max = rating[j]; > } > for(j=1; j<=p; j++) > { > if(rating[j]==max) > sim[j] = false; > if(rating[j]==min) > simp[j]++; > // printf("sim[%d] = %d max = %d, min = %d\n",j,sim[j],max,min); > } > > } > exist = false; > for(i=1; i<=p; i++) > { > if(simp[i]<=n*0.5) > sim[i] = false; > if(sim[i]) > exist = true; > } > if(exist) > { > for(i=1; !sim[i]; i++); > printf("%d",i); > for(i++; i<=p; i++) > if(sim[i]) > printf(" %d",i); > printf("\n"); > } > else > printf("0\n"); > // scanf("\n"); > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator