Find Pairs
Practice
3.8 (15 votes)
Basic programming
Problem
18% Success 5510 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given an array \(A\) of \(N \) integers. Find the number of unordered pairs \((i,j)\), \(1 \leq i, j \leq N\) such that
- \(L \le A[i] + A[j] \le R\)
- \(A[i] \oplus A[j]\) is odd where \(\oplus\) represents bitwise XOR operation.
Input format
- The first line contains three space-separated integers \(N \ L \ R\).
- The next line contains \(N\) space-separated integers denoting the array \(A\)
Output format
Print the number of unordered pairs \((i,j)\) which satisfy the above conditions in a new line.
Constraints
\(1 \le N \le 10^5\)
\(1 \le L \le R \le 10^{18}\)
\(1 \le A[i] \le 10^{18}\)
Explanation
Following unordered pairs satisfy the above conditions:
- \((1,2) \)
- \((1,4)\)
- \((2,3)\)
- \((3,4)\)
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
77 votes
Tags:
ApprovedBasic ProgrammingEasyImplementationOpen
Points:20
65 votes
Tags:
Basic ProgrammingMath BasicBasics of ImplementationC++
Points:20
7 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output