Title description:
-A bug falls into a dry well. It climbs up n centimeters during the day, but drops several centimeters at night when it rests. Through analysis, it is found that the insects will drop by n/2 cm on the first night, the insects will drop by (n/2+n/4) cm on the second night, and the insects will drop by (n/2+n/4) on the third night. +n/8) centimeters,..., and so on. If the depth of the well is m meters, how many days can this diligent bug crawl out of the dry well?
Input description:
Single group input.
Each group of input data occupies 1 line.
Enter two positive integers n and m in each line, and 50 m<n<100 m.
m<=100, enter the data to ensure that the problem is solved.
Output description:
Output a positive integer, that is, the first few days the bug crawls out of the dry well.
Sample input:
60 1
Sample output:
3
Code:
int gg(int n, int m, int sum){
if(n>=m) return sum;
else{
sum = sum++;
return gg(n,(m-n/(pow(2,sum-1))),sum);
}
}
void main(){
int ggV = gg(60,100,1);
}