题目链接:http://acm.tju.edu.cn/toj/showp3470.html
Time Limit: 4.0 Seconds Memory Limit: 65536K
Total Runs: 211 Accepted Runs: 191
ZSJ likes travel, and sometimes his may find some place that unknow to people. Once he found such a place, he will tell his friend ZXT about this. A few days before, ZXT found a mysterious place. At this place, he saw a big stone-gate. Beside this gate, there are some mysterious letters that ZSJ can't read. So he drew these letters on a piece of paper and went back home to ask ZXT for help. After a few days of hard work, ZXT told ZSJ that : If he want to open the door, he must find the certain integer between 1 and N (inclusively) that fits a fixed condition, but she can't tell what the condition is because she can't understand all those mysterious letters. But the good news is: if ZSJ trys an integer k, he can get one of the three piece of information from the mysterious stone-door: k is just the number that required, k is smaller than the required integere and k is greater than the required integer. Knowing about this, ZSJ decide to use the following method to get the required integer:
x <- 1 y <- N while (true) { m <- (x+y)/2 try the number m and if m is the required integer, break if m is smaller, x = m + 1 if m is greater, y = m - 1 }ZSJ is sure that he can get the required integer by the method mentioned above. But he has a question that when using this method, how many integers he has to try at most.
Input
The first line of input file is a sigle integer T, the number of test cases. Then T lines follows, each line contains a sigle integer N . Its meaning has mentioned above. (1 ≤ T ≤ 27; 1 ≤ N ≤ 100000).
Output
For each test cases, output a single integer: the number of integers he has to try at most.
Sample Input
2 10 427
Sample Output
4 9
Hint: In the first test cases, the possible key integer to open the door is 1, 2, 3, 4, 5, 6, 7, 8, 9. If the key integer is 1, using the methord above, ZSJ has to try 3 integers: {5, 2, 1}; if the key integer is 2, he has to try: {5, 2}; and so on. When the key integer is 4, he has to try most integers: {5, 2, 3, 4}. So the answer of the first test case is 4.
水题不多bb:
#include <stdio.h>
int main(){
int n,T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
int i = 1,k = 0;
while (i<n){
i *= 2;
k++;
}
printf("%d\n",k);
}
return 0;
}