Skip to content

Instantly share code, notes, and snippets.

@torpedo87
Created March 7, 2017 02:02
Show Gist options
  • Save torpedo87/437ee644603547f93378cd41c2940bb2 to your computer and use it in GitHub Desktop.
Save torpedo87/437ee644603547f93378cd41c2940bb2 to your computer and use it in GitHub Desktop.
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