From ec9fe743da237adc8eec0a992f08828ec9470043 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 3 Jan 2021 20:44:28 +0800 Subject: [PATCH] =?UTF-8?q?#159.=20=E3=80=90=E6=A8=A1=E6=9D=BF=E3=80=91?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=BC=82=E6=88=96=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/7564 --- S2OJ/159/159.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 S2OJ/159/159.cpp diff --git a/S2OJ/159/159.cpp b/S2OJ/159/159.cpp new file mode 100644 index 00000000..66ca04a3 --- /dev/null +++ b/S2OJ/159/159.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +int n; +long long t, ans, p[60]; + +void insert(long long x) { + for (int i = 50; i >= 0; i--) { + if (x & (1ll << i)) { + if (!p[i]) { + p[i] = x; + break; + } else { + x ^= p[i]; + } + } + } +} + +int main() { + cin >> n; + for (int i = 1; i <= n; i++) { + cin >> t; + insert(t); + } + for (int i = 50; i >= 0; i--) { + if ((ans ^ p[i]) > ans) { + ans ^= p[i]; + } + } + cout << ans << endl; + return 0; +}