按照顺寻循环淘汰数字的问题,是如何使用C语言的程序编写技术代码的方式去解答的

Problem Description
  You must have some knowledge with circle games in ACM problems, such as Joseph Ring problem. Today we are going to introduce a new circle game described as follows. There is a circle which contains M points, numbered from 0 to M-1. At first, n students stand in different points of the circle. It is possible that more than one student stand in the same point. For each second, each student moves one step forward in clockwise direction. The following picture gives us an example of that M equals to 8 and n equals to 3. Initially, the first student S1 stands in the point 0, the second student S2 stands in the point 2 and the third student stands in the point 7. After 2 seconds, they will change their positions as the right part of the picture.

At the beginning of the game, Tracy writes down the positions of all students. Then he will go to sleep and students will abide by the above rules to make this game run until Tracy wake up. After a period of time, Tracy wakes up. He finds it is very hard to identify where the first student S1 stands in and where the second student S2 stands in and so on, because all students are the exactly similar and unable to be distinguished. So Tracy records all the positions of students and writes down the XOR sum of these positions (The XOR sum of an array A means A[0] xor A[1] xor … A[n-2] xor A[n-1] and xor is the exclusive or operation, for example 0111 xor 1011 = 1100). Now Tracy wants you to help him to know how many seconds he had slept. To simplify the problem, the number of points is always a power of 2 like 2m.
Furthermore, Tracy knows that the time he slept is not greater than T. Please note that the time Tracy slept must be greater than zero. There may have many different periods of time corresponding with the above conditions.

Input
  There are several test cases, each test case firstly contains four integers n, m, S, T. S is the XOR sum of students’ positions when Tracy wakes up. Another 3 integers n, m, T are described as the above. Then n integers will follow in the next line, which represent the positions of students initially. The input will finish with the end of file.
0 < n <= 100000, 0 < m <= 50, 0 <= S< 250, 0 < T <= 1016 and the student position is in the range [0, 2m).

Output
  For each test case, output the number of possible periods of time that Tracy had slept and matched the above restrictions. Please output zero if no time matched.

Sample Input
3 3 7 5
0 2 7
5 3 7 5
1 2 3 4 5
4 4 0 10
1 3 5 7
6 5 18 100
22 10 18 20 2 10

Sample Output
1
0
4
50

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
C语言循环单链表解决约瑟夫问题
1
如何用c语言循环结构编写这个程序?
2
一个c语言的算法循环问题
0
数字连乘的一个算法问题,循环的计算用C语言的程序设计的办法
0
循环队列的旋转的一个算法问题怎么利用C语言的程序的编写来求解的
0
分类的分循环的问题算法,采用C程序语言的设计的思路是什么
0
循环跳跃数的一个输出问题的算法,怎么采用C语言的程序的方式来实现
0
循环队列在旋转数组上的运用问题,怎么利用C语言的程序的设计的技术实现
0
循环小数的求解得到的概率问题的算法,运用C语言的程序的设计的方式如何实现
4
一个很简单的c语言循环输入问题。
0
通过程序判断s2 是s1的亲和串,具体使用C语言这个程序设计语言的代码的编写的技术如何实现的?
0
多重循环中的求数字的问题,怎么利用C程序的编写程序的语言代码的实现的思想?
0
C语言的编程思想去寻找满足条件的循环数字的做法,怎么用程序的代码的思路去实现的呢?
0
数字的迭代循环匹配问题,怎么利用C语言的程序的代码的编写从而实现这个问题求解?
0
循环队列的数数的问题,怎么采用C语言代码程序编写的过程去实现程序的编制
0
通过循环迭代计算e的值,怎么利用C语言的程序代码编写的方式进行程序的编写的?
0
自循环数字的精确求解问题,运用的是C语言的程序设计的过程的方法,怎么才能实现的
0
循环列表的一个数据运用的问题,怎么使用C语言的程序的设计的办法去做这个问题的解答
0
确定i和j之间所有数字的最大循环长度,使用C语言编写的程序来实现这个算法如何来编写程序代码
0
u Calculate e连加问题的循环,怎么使用C语言的程序编写出来的代码的形式和方法去计算的