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:用C++编译的,过不了(运行超时)----------用c重写,用c编译过了, 求大神解释下In Reply To:用C++编译的,过不了 Posted by:anothing at 2014-10-25 08:41:00 #include <stdio.h> #include <string.h> int dn[1000003]; void main() { int c,d,n; int num,i; int r,zero; int sum; scanf("%d",&c); while(c--) { memset(dn,0,sizeof(dn)); sum = 0; zero=0; scanf("%d %d",&d,&n); for(i = 0; i < n; i++) { scanf("%d",&num); r=num%d; dn[zero]++; if(d-r+zero>=d) { sum+=dn[d-r+zero-d]; } else { sum+=dn[d-r+zero]; } if(zero<r) { zero=zero-r+d; } else { zero=zero-r; } } printf("%d\n",sum); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator