编程知识 cdmana.com

Simple questions at school OJ, but the answers are always wrong

Bear 2 dreams of becoming the largest bear in the world ... Or at least bigger than his brother bear .
It is known that bear II now weighs a, The bear weighs b.
Every year , The weight gain of bear II is... Of last year 3 times , Bear's weight gain is... Of last year 2 times .
Now Xiong Er wants to know how many years it will take at least , It can weigh more than its brother .

Input
Two positive integers per line a and b, There is a space between the two ,a No more than b, And no more than 10000
Output
Each line outputs a positive integer , That is, it takes at least a few years for Bear 2 to weigh more than bear .
The sample input Copy
4 7
2 3
Sample output Copy
2
2

#include<stdio.h>
int main()
{
int a,b,year=0;
while(scanf("%d %d",&a,&b)!=EOF){
while(a<=b){
a=3a;
b=2
b;
year++;
}
printf("%d\n",year);
year=0;
}
return 0;
}

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/12/20211207162230326K.html

Scroll to Top