
115  The 12th Zhejiang University Programming Contest  A
Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap. Here is another version of Nim game. There are N piles of stones on the table. Alice first chooses some CONSECUTIVE piles of stones to play the Nim game with Tom. Also, Alice will make the first move. Alice wants to know how many ways of choosing can make her win the game if both players play optimally. You are given a sequence a[0],a[1], ... a[N1] of positive integers to indicate the number of stones in each pile. The sequence a[0]...a[N1] of length N is generated by the following code:
InputThere are multiple test cases. The first line of input is an integer T(T ≤ 100) indicates the number of test cases. Then T test cases follow. Each test case is represented by a line containing four integers 3 integers N, S and W, separated by spaces. (0 < N ≤ 10^{5}, 0 < S, W ≤ 10^{9}) OutputFor each test case, output the number of ways to win the game. Sample Input2 3 1 1 3 2 1 Sample Output4 5
Author: CAO, Peng 