-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBearAndBigBrother.cpp
More file actions
40 lines (34 loc) · 891 Bytes
/
BearAndBigBrother.cpp
File metadata and controls
40 lines (34 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Bear Limak wants to become the largest of bears, or
at least to become larger than his brother Bob.
Right now, Limak and Bob weigh a and b respectively.
It's guaranteed that Limak's weight is smaller than
or equal to his brother's weight.
Limak eats a lot and his weight is tripled after every
year, while Bob's weight is doubled after every year.
After how many full years will Limak become
strictly larger (strictly heavier) than Bob?
*/
#include <iostream>
int main()
{
long long int a, b, yrs = 0;
std::cin >> a;
std::cin >> b;
// If the mass is the same, return 0 full years
if(a == b)
{
std::cout << ++yrs << std::endl;
return 0;
}
// Loop until the number is exceeded
while(b >= a)
{
a = 3 * a;
b = 2 * b;
yrs++;
//std::cout << "a: " << a << ", b: " << b << ", years: " <<yrs << std::endl;
}
std::cout << yrs << std::endl;
return 0;
}