https://www.hackerrank.com/challenges/divisible-sum-pairs/problem
HackerRank - Divisible Sum Pairs
#!/bin/python3
import math
import os
import random
import re
import sys
def divisibleSumPairs(n, k, ar):
count = 0
for i in range(0, n):
for j in range(0, n):
if(i >= j):
continue
if((ar[i] + ar[j]) % k == 0):
count += 1
return count
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
nk = input().split()
n = int(nk[0])
k = int(nk[1])
ar = list(map(int, input().rstrip().split()))
result = divisibleSumPairs(n, k, ar)
fptr.write(str(result) + '\n')
fptr.close()
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
HackerRank - Day of the Programmer (0) | 2019.01.25 |
---|---|
HackerRank - Migratory Birds (0) | 2019.01.24 |
HackerRank - Birthday Chocolate (0) | 2019.01.22 |
HackerRank - Breaking the Records (0) | 2019.01.21 |
HackerRank - Between Two Sets (0) | 2019.01.20 |