AlgoUniversity
  • Go Back
Discussion
Pair Condition :

Author

Akash

Difficulty Level : Hard

Submissions : 158

Asked In : Tekion

Marks :10

: 2 | : 3

We are given an array $$$A$$$ and an integer $$$X$$$. We have to find the number of pairs with the following conditions:

1. $$$i<j$$$

2. $$$A[i]=A[j]$$$

3. $$$i*j$$$ is divisible by $$$X$$$

We use 1-based indexing in this problem.

Input

The first line contains two integers, $$$n$$$ $$$(1 \le n \le 10^5)$$$ and $$$x$$$ $$$(1 \le x \le 10^9)$$$.

The second line contains $$$n$$$ integers, $$$A_1,A_2,...A_n$$$, $$$(1 \le A_i \le 10^9)$$$.

Output

Return the total number of pairs satisfying the given condition.

Example

Input
3 2
2 2 2
Output
2

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.