| 比赛 | 
    20120711 | 
    评测结果 | 
    AWAAAWWWATTT | 
    | 题目名称 | 
    平衡奶牛 | 
    最终得分 | 
    41 | 
    | 用户昵称 | 
    王者自由 | 
    运行时间 | 
    3.391 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.96 MiB  | 
    | 提交时间 | 
    2012-07-11 08:54:28 | 
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int N = 100000 + 10;
int n, k, b, s, t;
int a[N], f[N];
int main() {
    freopen("balline.in", "r", stdin);
    freopen("balline.out", "w", stdout);
    scanf("%d %d", &n, &k);
    b = 1 << k;
    for(int i=1; i<=n; i++) {
        scanf("%d", a+i);
        a[i] %= b;
    }
    for(int i=1; i<n; i++) {
        t = a[i];
        for(int j=i+1; j<=n; j++) {
            t ^= a[j];
            if(t == 0)
                s = max(s, j-i+1);
        }
    }
    if(n <= 1)
        s = 0;
    printf("%d\n", s);
    return 0;
}