diff --git a/algorithms/bit-manipulation/sansa-and-xor/README.md b/algorithms/bit-manipulation/sansa-and-xor/README.md new file mode 100644 index 0000000..2ffc313 --- /dev/null +++ b/algorithms/bit-manipulation/sansa-and-xor/README.md @@ -0,0 +1 @@ + diff --git a/algorithms/bit-manipulation/sansa-and-xor/solution.cpp b/algorithms/bit-manipulation/sansa-and-xor/solution.cpp new file mode 100644 index 0000000..4546be9 --- /dev/null +++ b/algorithms/bit-manipulation/sansa-and-xor/solution.cpp @@ -0,0 +1,29 @@ +#include + +int main() +{ + using namespace std; + size_t T; + cin >> T; + + while (T--) { + + size_t N; + cin >> N; + + int value, result; + result = 0; + + for (size_t i = 0; i < N; ++i) { + + cin >> value; + + if (((i + 1) & 1) && ((N - i) & 1)) + result ^= value; + } + + cout << (result^0) << endl; + } + + return 0; +}