试一下bitset。
然而RE...最后发现是数据不全,读入优化炸了,去掉就好了。
/* Footprints In The Blood Soaked Snow */ #include <cstdio> #include <bitset> using namespace std; const int maxn = 2000005; int n, sum, ans; bitset<maxn> f; int main() { scanf("%d", &n); f[0] = 1; for(int i = 1; i <= n; i++) { int x; scanf("%d", &x); sum += x; f ^= f << x; } for(int i = 1; i <= sum; i++) if(f[i]) ans ^= i; printf("%d\n", ans); return 0; }