Created
March 7, 2017 02:02
-
-
Save torpedo87/437ee644603547f93378cd41c2940bb2 to your computer and use it in GitHub Desktop.
divisible sum pairs(https://www.hackerrank.com/challenges/divisible-sum-pairs)
This file contains 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
function main() { | |
var n_temp = readLine().split(' '); | |
var n = parseInt(n_temp[0]); | |
var k = parseInt(n_temp[1]); | |
a = readLine().split(' '); | |
a = a.map(Number); | |
var result=0; | |
for(var i=0; i<n; i++){ | |
for(var j=i+1; j<n; j++){ | |
if((a[i]+a[j])%k==0){ | |
result+=1; | |
} | |
} | |
} | |
console.log(result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment