arc098D Xor Sum 2

标程:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int N=200005;
 5 int n,l;
 6 ll ans,sum,a[N];
 7 int main()
 8 {
 9     scanf("%d",&n);l=1;
10     for (int i=1;i<=n;i++) 
11     {
12         scanf("%lld",&a[i]);
13         while ((sum^a[i])!=sum+a[i]) sum^=a[l++];
14        ans+=i-l+1;sum^=a[i];
15     }
16     printf("%lld\n",ans);
17     return 0;
18 }

猜你喜欢

转载自www.cnblogs.com/Scx117/p/9112954.html