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 |
为什么还是TLE?代码: #include<iostream> using namespace std; int b[1000001]={0}; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int k,d,a[50000]={0},x; long long ans=0; cin>>k>>d; for(int j=0;j<k;j++) b[j]=0; b[0]=1; for(int j=1;j<=d;j++) { cin>>x; a[j]=a[j-1]+x; a[j]=a[j]%k; b[a[j]]++; } for(int j=0;j<k;j++) ans+=b[j]*(b[j]-1)/2; cout<<ans<<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