Pair Count
Practice
3.7 (245 votes)
Mathematics
Sieve
Approved
Easy Medium
Problem
60% Success 5647 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are given an array A={a0,a1...aN1} and an integer D. Find the total number of un-ordered pairs (i,j) where ij such that aiaj0(modD).

INPUT

The first line of each test file contains two space separated integers N and D, where N denotes the size of array A and D is as described above. Next line contains N space separated integers a0aN1 denoting array A .

OUTPUT

Output a single line containing the number of pairs as described in problem statement.

CONSTRAINTS

  • 1N106
  • 1D106
  • 1ai109

Please login to use the editor

You need to be logged in to access the code editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
Medium
Points:30
Tags:
MediumAd-HocLinear AlgebraMatrix ExponentiationAlgorithmsMathematicsOpenApproved
Points:20
48 votes
Tags:
ApprovedBasic ProgrammingEasyImplementationOpen
Editorial

Login to unlock the editorial