CF1848F.Vika and Wiki
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recently, Vika was studying her favorite internet resource - Wikipedia.
On the expanses of Wikipedia, she read about an interesting mathematical operation bitwise XOR, denoted by ⊕ .
Vika began to study the properties of this mysterious operation. To do this, she took an array a consisting of n non-negative integers and applied the following operation to all its elements at the same time: ai=ai⊕a(i+1)modn . Here xmody denotes the remainder of dividing x by y . The elements of the array are numbered starting from 0 .
Since it is not enough to perform the above actions once for a complete study, Vika repeats them until the array a becomes all zeros.
Determine how many of the above actions it will take to make all elements of the array a zero. If this moment never comes, output −1 .
输入格式
The first line contains a single integer n ( 1≤n≤220 ) - the length of the array a .
It is guaranteed that n can be represented as 2k for some integer k ( 0≤k≤20 ).
The second line contains n integers a0,a1,a2,…,an−1 ( 0≤ai≤109 ) - the elements of the array a .
输出格式
Output a single number - the minimum number of actions required to make all elements of the array a zero, or −1 if the array a will never become zero.
输入输出样例
输入#1
4 1 2 1 2
输出#1
2
输入#2
2 0 0
输出#2
0
输入#3
1 14
输出#3
1
输入#4
8 0 1 2 3 4 5 6 7
输出#4
5
说明/提示
In the first example, after one operation, the array a will become equal to [3,3,3,3] . After one more operation, it will become equal to [0,0,0,0] .
In the second example, the array a initially consists only of zeros.
In the third example, after one operation, the array a will become equal to [0] .