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 |
用C++编译的,过不了#include<iostream> using namespace std; int dn[1000001]; int main() { int c; int d,n; int num,i=0; int r; int zero; long long sum; cin>>c; while(c--) { cin>>d>>n; memset(dn,0,sizeof(dn)); zero=0; sum=0; for(i=0;i<n;i++) { cin>>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; } } cout<<sum<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator