Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么还是TLE?

Posted by sunqian1998 at 2012-05-14 20:46:24 on Problem 3844
代码:
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator