Divisible Pair Count

Easy
ArrayHash TableMathContest
You are given n integers and a positive integer k. Count the number of index pairs (i, j) with i < j such that nums[i] + nums[j] is divisible by k. Input format: - First line: n k - Second line: n integers Print a single integer: the number of valid pairs. Values may be negative, and the answer can exceed a 32-bit integer.

Constraints

1 <= n <= 10^5
1 <= k <= 10^9
-10^9 <= nums[i] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit