
题目电波: HDU--5269 ZYB loves Xor I
首先我们先解决 ai xor aj 每个数转化为二进制 我们用字典树统计 每个节点 0 和 1 的出现的个数
#include<bits/stdc++.h> using namespace std; #define maxn 50000 #define mod 998244353; struct ac{ ]; void init(){ sum=; memset(nex,,sizeof(nex)); } }tre[maxn*]; int tot; ; void init(){ tot=;ans=; memset(tre,,sizeof(tre)); } void add(int x){ ; ;j<=;j++){ <<j)); //cout<<fa<<endl; ]){ ]; ans+=1LL*(1LL*<<j)*tre[i].sum%mod; ans%=mod; } ){ tre[k].nex[fa]=++tot; tre[tot].init(); } k=tre[k].nex[fa]; tre[k].sum++; } } int main(){ ; cin>>t; while(t--){ init(); int n; cin>>n; ;j<n;j++){ int x; scanf("%d",&x); add(x); } ans*=; ans%=mod; printf("Case #%d: %lld\n",tt++,ans); } }