Cleartrip.com Interview Question for Software Developers
- 0of 0 votes
Given an array A of size N, where the ith integer of the array is A[i] and has a value ranging between 1 and 1000 inclusive, you need to help Monk with the following task :- itsvks February 10, 2017 in India
Given 3 additional numbers K, X and Y, you need to report the number of un-ordered pairs of elements (i,j) from this array, such that (1≤i<j≤N), (A[i]+A[j])%K=X, and (A[i]×A[j])%K=Y.
Input Format :
The first line contains 4 space separated integers N, K and X and Y. The next line contains N space separated integers where the ith integer denotes A[i].
Output Format :
Print the required number of ordered pairs of array elements on a single line. As the answer could be rather large, beware of integer overflows.
2 ≤ N ≤ 10 raised to power 5
1 ≤ K ≤ 10 raised to power 6
0 ≤ X, Y < K
5 2 1 0
1 2 3 2 1
| Report Duplicate | Flag | PURGE
Cleartrip.com Software Developer Algorithm
Interview Type: Written Test
Open Chat in New Window