Same AND/OR
Practice
5 (3 votes)
Basic math
Bit manipulation
Arrays
Observation
C++
Math
Problem
53% Success 380 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array \(A\) of length \(N\). Find the number of subarrays of length greater than one whose Bitwise AND and Bitwise OR are the same.

Input Format:

  • The first line contains an integer \(T\), denoting the number of test cases.
  • The first line of each test case contains an integer \(N\), denoting the length of the array \(A\).
  • The second line of each test case contains \(N\) space-separated integers, denoting the elements of array \(A\).

Output Format:

For each test case, print the number of subarrays of length greater than one whose Bitwise AND and Bitwise OR are the same.

Constraints:

\(1 <= T <= 10\)

\(1 <= N <= 10^5\)

\(1 <= A[i] <= 10^5\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
5 votes
Tags:
Very-Easy
Points:10
15 votes
Tags:
Basic MathAlgorithmsMathamaticsMath
Points:10
11 votes
Tags:
Very-Easy