题目贴在最后。
思路:
这个题也很简单,比赛的时候我一直过不了。。。。。后来才发现绳子的长度比较大,要用long型才可以AC。积累经验,加油加油。
代码:
// 本题为考试多行输入输出规范示例,无需提交,不计分。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i ++) {
arr[i] = scanner.nextLong();
}
for (int i = 0; i < n; i ++) {
long temp = arr[i];
long res = 1;
while (temp > 1) {
temp = Math.max(temp / 2, temp - temp / 2);
res ++;
}
System.out.println(res);
}
}
}