Skip to content

Commit 920b352

Browse files
authored
Create 2749.js
1 parent e05fa56 commit 920b352

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

2501-3000/2749.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function makeTheIntegerZero(num1, num2) {
2+
for (let t = 0; t <= 60; t++) {
3+
let s = BigInt(num1) - BigInt(t) * BigInt(num2);
4+
if (s < 0n) continue;
5+
if (s < BigInt(t)) continue;
6+
let ones = popcountBigInt(s);
7+
if (ones <= t) return t;
8+
}
9+
return -1;
10+
}
11+
12+
function popcountBigInt(x) {
13+
let cnt = 0;
14+
while (x > 0n) {
15+
if (x & 1n) cnt++;
16+
x >>= 1n;
17+
}
18+
return cnt;
19+
}

0 commit comments

Comments
 (0)