公平划分

若条件满足,则所有数异或和为零,这时候随便分都可以,答案为2^n-2,否则答案为0

#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI;
typedef map<int, int> MII;

void makedata() {
    freopen("input.txt", "w", stdout);
    fclose(stdout);
}

int n;
lint a[100];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    lint x = a[0];
    for (int i = 1; i < n; i++) x ^= a[i];
    if (x != 0) cout << 0 << endl;
    else cout << (1LL << n) - 2 << endl;
    return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-12
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案