https://www.acmicpc.net/problem/10986
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
s=[0]*n
c=[0]*(m)
s[0] = a[0]
answer = 0
for i in range(1,n):
s[i] = s[i-1] + a[i]
for i in range(n):
temp = s[i]%m
if temp == 0:
answer+=1
c[temp]+=1
for i in c:
answer += i*(i-1)//2
print(answer)
|
cs |