Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3568a0b

Browse files
1
1 parent 81deba8 commit 3568a0b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎src/main/kotlin/p27xx/Problem2749.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package p27xx
2+
3+
import util.expect
4+
5+
fun main() {
6+
class Solution {
7+
fun makeTheIntegerZero(num1: Int, num2: Int): Int {
8+
var result = 1
9+
while (true) {
10+
val num = num1 - num2.toLong() * result
11+
when {
12+
num < result -> {
13+
return -1
14+
}
15+
16+
result >= num.countOneBits() -> {
17+
return result
18+
}
19+
20+
else -> result++
21+
}
22+
}
23+
}
24+
}
25+
26+
expect {
27+
Solution().makeTheIntegerZero(
28+
5, 7
29+
)
30+
}
31+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /