- 连续数之和
- 2018-10-28 16:26:27 @
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500010;
int n,k;
ll a[maxn];
ll sum[maxn];
int main()
{
int i,j;
scanf("%d %lld",&n,&k);
sum[0] = 0;
for(i = 1; i <= n; i++){
scanf("%lld",&a[i]);
a[i] = a[i] % k;
sum[i] = sum[i - 1] + a[i];
}
ll ans = 0;
for(i = 1; i <= n; i++)
for(j = i; j <= n; j++)
{
if((sum[j] - sum[i - 1]) % k == 0) ans++;
}
printf("%lld\n",ans % 1234567);
return 0;
}
0 条评论
目前还没有评论...