-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10986.cpp
More file actions
58 lines (48 loc) · 899 Bytes
/
10986.cpp
File metadata and controls
58 lines (48 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
#define vt vector
#define en '\n'
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
const int INF = 0x3f3f3f3f; const int mINF = 0xc0c0c0c0;
const ll LINF = 0x3f3f3f3f3f3f3f3f; const ll mLINF = 0xc0c0c0c0c0c0c0c0;
int T = 1;
ll psum[1000001];
ll mod[1000001];
ll cnt[1001];
ll ans;
int N,M;
void sol() {
cin >> N >> M;
int x;
for(int i=1; i<=N; ++i) {
cin >> x;
psum[i] = psum[i-1] + x;
}
for(int i=1; i<=N; ++i) {
mod[i] = psum[i] % M;
}
for(int i=1; i<=N; ++i) {
cnt[mod[i]]++;
}
for(int i=0; i<M; ++i) {
ll x = cnt[i];
if(x) {
if(i == 0) ans += x;
ans += 1LL * x * (x-1) / 2;
}
}
cout << ans << en;
return;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
while(T--) {
sol();
}
return 0;
}