You are viewing a single comment's thread. Return to all comments →
Nice I got something similar :)
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int a[] = new int[k]; int count = 0; for(int i=0; i < n; i++){ int remainder = in.nextInt() % k; int complement = (remainder == 0) ? 0:k-remainder; count += a[complement]; a[remainder]++; } System.out.println(count); }
Seems like cookies are disabled on this browser, please enable them to open this website
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
Nice I got something similar :)