add: 211227
This commit is contained in:
parent
e9790e25ab
commit
da919308b6
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2112)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2112 211226.cpp)
|
ADD_EXECUTABLE(2112 211227.cpp)
|
||||||
Loading…
Reference in New Issue