Yurii is certain he can do everything. However, would he be able to tackle this assignment? He has a cluster a comprising of n positive integers. How about we call a subarray a[l...r] great if the accompanying conditions are all the while fulfilled: l+1≤r−1, I. e. the subarray has length something like 3;
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
Yurii is certain he can do everything. However, would he be able to tackle this assignment?
He has a cluster a comprising of n positive integers. How about we call a subarray a[l...r] great if the accompanying conditions are all the while fulfilled:
l+1≤r−1, I. e. the subarray has length something like 3;
(al⊕ar)=(al+1+al+2+… +ar−2+ar−1), where ⊕ indicates the bitwise XOR activity.
All in all, a subarray is acceptable if the bitwise XOR of the two boundary components is equivalent to the amount of the remainder of the components.
Yurii needs to compute the absolute number of good subarrays. What is it equivalent to?
A cluster c is a subarray of an exhibit d if c can be gotten from d by erasure of a few (conceivably, zero or all) components from the start and a few (perhaps, zero or all) components from the end.
Input
The principal line contains a solitary integer n (3≤n≤2⋅105) — the length of a.
The subsequent line contains n integers a1,a2,… ,an (1≤
Output
Output a solitary integer — the number of good subarrays.
Step by step
Solved in 4 steps with 1 images