From 9c577f8a7525233e5a35a9e261793b8b69ad4001 Mon Sep 17 00:00:00 2001 From: Dmitry Kokorin Date: Mon, 12 Sep 2016 17:00:53 +0300 Subject: [PATCH] counter-game: initial commit --- .../bit-manipulation/counter-game/README.md | 1 + .../bit-manipulation/counter-game/game.cpp | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 algorithms/bit-manipulation/counter-game/README.md create mode 100644 algorithms/bit-manipulation/counter-game/game.cpp diff --git a/algorithms/bit-manipulation/counter-game/README.md b/algorithms/bit-manipulation/counter-game/README.md new file mode 100644 index 0000000..7647468 --- /dev/null +++ b/algorithms/bit-manipulation/counter-game/README.md @@ -0,0 +1 @@ + diff --git a/algorithms/bit-manipulation/counter-game/game.cpp b/algorithms/bit-manipulation/counter-game/game.cpp new file mode 100644 index 0000000..7c71050 --- /dev/null +++ b/algorithms/bit-manipulation/counter-game/game.cpp @@ -0,0 +1,27 @@ +#include +#include + +int main() +{ + using namespace std; + + size_t T; + cin >> T; + + while (T--) { + + uint64_t N, count; + cin >> N; + + --N; + + for (count = 0; N; ++count) { + + N &= N - 1; + } + + cout << ((count & 1) ? "Louise" : "Richard") << endl; + } + + return 0; +}