forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiv.py
More file actions
36 lines (24 loc) · 629 Bytes
/
div.py
File metadata and controls
36 lines (24 loc) · 629 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
#!/bin/python
import math
import os
import random
import re
import sys
# Complete the divisibleSumPairs function below.
def divisibleSumPairs(n, k, ar):
# Brute Force
count = 0
for i in range(n-1):
for j in range(i+1,n):
if (ar[i]+ar[j])%k == 0:
count += 1
return count
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
nk = raw_input().split()
n = int(nk[0])
k = int(nk[1])
ar = map(int, raw_input().rstrip().split())
result = divisibleSumPairs(n, k, ar)
fptr.write(str(result) + '\n')
fptr.close()