Question is pretty straight-forward.
You are given a set of 'n' numbers. You need to find total pairs of numbers whose sum is divisible by 5.
Note: Pair of numbers means collection of any two numbers from the set.
See sample test-case for more understanding.
Input format:
First line consist of total numbers given as 'n'.
Next Line consists of 'n' numbers seperated by space.
Output format:
Output total pairs whose sum is divisible by 5.
Constraints:
1 <= n <= 10^6
1 <= number <= 10^6
Total pairs possible in this test-case are: (1, 2), (1, 3) and (2, 3).
(1, 2) --> 1 + 2 == 3 (not divisible by 5)
(1, 3) --> 1 + 3 == 4 (not divisible by 5)
(2, 3) --> 2 + 3 == 5 (divisible by 5)
Hence, answer is 1 as only one pair has a sum divisible by 5.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor