在一颗未知硬度等级的行星上,因为飞船无法降落,你使用探测器进行探测。由于星球表面凹凸不平,具有不同深度的坑,你可以选择探测任意深度的地表,但是深度大于或等于一定程度f(0的坑上释放探测器,如果探测器可以回收,则能继续使用,如果探测器无法回收,则无法继续使用这个探测器。由于探测器在地表深度为f的地方所传回的硬度数据是最准确的,现在要求你计算找到该深度所需的最小实验次数是?(假设深度数据都是整数)
示例1
输入
1,2
输出
2
备注:
数据范围:1
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ public int minTests (int k, int n) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ int minTests(int k, int n) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param k int整型 # @param n int整型 # @return int整型 # class Solution: def minTests(self , k , n ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ public int minTests (int k, int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ function minTests( k , n ) { // write code here } module.exports = { minTests : minTests };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param k int整型 # @param n int整型 # @return int整型 # class Solution: def minTests(self , k: int, n: int) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ func minTests( k int , n int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ int minTests(int k, int n ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param k int整型 # @param n int整型 # @return int整型 # class Solution def minTests(k, n) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ def minTests(k: Int,n: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ fun minTests(k: Int,n: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ public int minTests (int k, int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ export function minTests(k: number, n: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ func minTests ( _ k: Int, _ n: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param k int整型 * @param n int整型 * @return int整型 */ pub fn minTests(&self, k: i32, n: i32) -> i32 { // write code here } }
1,2
2