diff --git a/README.md b/README.md index 791a2e2c..4e74f727 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ In this repository, you can find the solutions (as source code) for the problems | [Nauman Chaudhary](https://github.com/nauman-chaudhary)
| Pakistan | Python | | | [Gourav Rusiya](https://github.com/GouravRusiya30)
| India | Java | https://www.hackerrank.com/gouravrusiya786 | | [Trushita Maurya](https://github.com/trushita23)
| India | Java +| [Saida Jahan](https://github.com/sasasaida)
| Bangladesh | C++, Python ### License [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://github.com/ows-ali/Hacktoberfest/blob/master/LICENSE) diff --git a/SPOJ/DANGER.cpp b/SPOJ/DANGER.cpp new file mode 100644 index 00000000..81cc3e13 --- /dev/null +++ b/SPOJ/DANGER.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ + while (true) + { + string s; + cin >> s; + if (s == "00e0") + break; + + int n = stod(s); + int a = floor(log2(n)); + int l = n - pow(2, a); + int result = 2 * l + 1; + + cout << result << endl; + } +} \ No newline at end of file