We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This solution is very nice. Because I got a longer piece of code. Good job.
publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);intn=in.nextInt();intk=in.nextInt();inta[]=newint[n];for(inta_i=0;a_i<n;a_i++){a[a_i]=in.nextInt();}intcount=0;//checking aginst the conditionfor(inti=0;i<(n-1);i++){for(intj=0;j<n;j++){if(i<j){if((a[i]+a[j])%k==0)count++;}}}System.out.println(count);}}
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
This solution is very nice. Because I got a longer piece of code. Good job.