In an array

0

0 votes
Open, Open, Open, One-dimensional, Arrays, 1-D, Data Structures, Easy, approved
Problem

You are given an array A of size N, where the ith integer of the array is A[i] and its value ranges between 1 and 1000 inclusive. You are required to complete the following task:

Assume that you are provided with 3 additional numbers K, X, and Y. Your task is to report the number of unordered pairs of elements (i,j) from this array, such that (1i<jN), (A[i]+A[j])%K=X, and (A[i]×A[j])%K=Y.

Input format

  • First line: Four space-separated integers N, KX, and Y
  • Next line: N space-separated integers where the ith integer denotes A[i]

Output format

Print the required number of ordered pairs of array elements in a single line. As the answer could be rather large, be careful of integer overflows.

Constraints

2N105

1K106

0X,Y<K

1A[i]1000

Sample Input
5 2 1 0
1 2 3 2 1
Sample Output
6
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

.

Contributers:
Editor Image

?