From 9ef89157976ec37c41585ce30eed708c8b3574e9 Mon Sep 17 00:00:00 2001 From: walker002 <44633512+walker002@users.noreply.github.com> Date: Wed, 31 Oct 2018 13:05:29 +0530 Subject: [PATCH] create strangecounter.cpp solution of strangecounter --- Algorithms/Implementation/strangecounter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Algorithms/Implementation/strangecounter.cpp diff --git a/Algorithms/Implementation/strangecounter.cpp b/Algorithms/Implementation/strangecounter.cpp new file mode 100644 index 0000000..157a3f7 --- /dev/null +++ b/Algorithms/Implementation/strangecounter.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +int main() { + unsigned long long val = 3; + unsigned long long idx = 1; + unsigned long long t; cin >> t; + while (t-idx >= val) { + idx += val; + val *= 2; + } + cout << val - (t - idx); + return 0; +}