SPOJ SUBXOR - SubXor [Trie]【思维】

题目链接:http://www.spoj.com/problems/SUBXOR/en/

————————————————————————————————————————————
SUBXOR - SubXor
no tags
A straightforward question. Given an array of positive integers you have to print the number of subarrays whose XOR is less than K.
Subarrays are defined as a sequence of continuous elements Ai, Ai+1, …, Aj . XOR of a subarray is defined as Ai^Ai+1^ … ^Aj.
Symbol ^ is Exclusive Or. You can read more about it here:
http://en.wikipedia.org/wiki/Exclusive_or

Input Format:

First line contains T, the number of test cases. Each of the test case consists of N and K in one line, followed by N space separated integers in next line.

Output Format:

For each test case, print the required answer.

Constraints:

1 ≤ T ≤ 10
1 ≤ N ≤ 10^5
1 ≤ A[i] ≤ 10^5
1 ≤ K ≤ 10^6
Sum of N over all testcases will not exceed 10^5.

Sample Input:

1
5 2
4 1 3 2 7
Sample Output:

3
Explanation:

Only subarrays satisfying the conditions are [1],[1,3,2] and [3,2].

————————————————————————————————————————————
题目大意:
给你一个序列,问你有多少个区间的所有元素异或和小于k

解题思路:

首先我们很容易想到,
对于一个区间异或和 可以先预处理出前缀异或和pre[],这样的话区间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值