80pts求调
查看原帖
80pts求调
1389432
sqrt_2楼主2025/6/24 22:55

只有task1没过,请各位大佬帮忙修改一下

#include<bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; ++ i)
#define Rof(i, a, b) for(int i = a; i >= b; -- i)
using namespace std;
int n, a[100010], b[100010], x[100010];
long long ans;
int st[2000] = {1};
int c[31] = {0, 0, 1, 2, 0, 4, 3, 8, 1, 0, 5, 16, 2, 32, 9, 6, 0, 64, 1, 128, 4, 10, 17, 256, 3, 0, 33, 2, 8, 512, 7};
int main()
{
	cin >> n;
	For(i, 1, n)
	{
		cin >> a[i];
		b[i] = c[a[i]];
		x[i] = x[i - 1] ^ b[i];
		st[x[i]] ++;
	}
	For(i, 0, 1023) if(st[i] > 1) ans += st[i] * (st[i] - 1) / 2;
	cout << ans;
    return 0;
}
2025/6/24 22:55
加载中...