kk
This commit is contained in:
19
src/main/java/com/dota/bit/_3133/Solution.java
Normal file
19
src/main/java/com/dota/bit/_3133/Solution.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package com.dota.bit._3133;
|
||||||
|
|
||||||
|
class Solution {
|
||||||
|
public long minEnd(int n, int x) {
|
||||||
|
long res = x;
|
||||||
|
long y = n - 1;
|
||||||
|
long a = 0;
|
||||||
|
while (y != 0) {
|
||||||
|
//找x第一个0
|
||||||
|
while ((x & (1 << a)) != 0) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
res |= (y & 1) << a;
|
||||||
|
y >>= 1;
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user