diff --git a/2112/211227.cpp b/2112/211227.cpp new file mode 100644 index 0000000..4913ebd --- /dev/null +++ b/2112/211227.cpp @@ -0,0 +1,14 @@ +#include + +class Solution { +public: + static int findComplement(int num) { + unsigned t = 1; + for (int x = num; x; t <<= 1, x >>= 1); + return (t - 1) ^ num; + } +}; + +int main() { + std::printf("%d\n", Solution::findComplement(9)); +} \ No newline at end of file diff --git a/2112/CMakeLists.txt b/2112/CMakeLists.txt index d05e6fd..c0b2453 100644 --- a/2112/CMakeLists.txt +++ b/2112/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2112) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2112 211226.cpp) \ No newline at end of file +ADD_EXECUTABLE(2112 211227.cpp) \ No newline at end of file