Created
June 14, 2022 06:54
-
-
Save mym0404/36d37157c420d209a4a53820bb0261a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, m = map(int, input().split()) | |
a = list(map(int, input().split())) | |
psum = [0] * (n + 1) | |
for i in range(n): | |
psum[i + 1] = (psum[i] + a[i]) % m | |
answer = 0 | |
remainder_cnt = [0] * m | |
remainder_cnt[0] = 1 | |
for i in range(1, n + 1): | |
answer += remainder_cnt[psum[i]] | |
remainder_cnt[psum[i]] += 1 | |
print(answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment