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 = \{ a_0, a_1...a_{N-1} \}\) and an integer D. Find the total number of un-ordered pairs \((i, j)\) where \(i \ne j\) such that \(a_i * a_j \equiv 0 \pmod D\).
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 \(a_0 \dotso a_{N-1}\) denoting array A .
OUTPUT
Output a single line containing the number of pairs as described in problem statement.
CONSTRAINTS
- \(1 \le N \le 10^6\)
- \(1 \le D \le 10^6\)
- \(1 \le a_i \le 10^9\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
11 votes
Tags:
Basic ProgrammingOpenApprovedEasyMathamatics
Points:30
11 votes
Tags:
ApprovedEasyMathNumber TheoryNumber theory
Points:30
4 votes
Tags:
ReadyMathematicsAlgorithmsApprovedEasy-Medium
Editorial