From 03734becc9209bc720b5f05ba47bc78c87248727 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Tue, 4 Jan 2022 13:13:00 +0800 Subject: [PATCH] add: 220104 --- 2201/220104.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 2201/220104.cpp diff --git a/2201/220104.cpp b/2201/220104.cpp new file mode 100644 index 0000000..3cbdb27 --- /dev/null +++ b/2201/220104.cpp @@ -0,0 +1,12 @@ +#include + +class Solution { +public: + static int bitwiseComplement(int n) { + return n ? ((1 << ((31 ^ __builtin_clz(n)) + 1)) - 1) ^ n : 1; + } +}; + +int main() { + std::printf("%d\n", Solution::bitwiseComplement(0)); +} \ No newline at end of file