 # Height after year

Practice

Author: Anurag
Tester: Anurag
Editorialist: Anurag

# DIFFICULTY:

EASY,MEDIUM,GREEDY,STRING,CAKEWALK, SIMPLE

Math ,String

# PROBLEM:

Root wants to become the largest , or at least to become larger than his brother stoke .

Right now, root and stoke height a and b respectively. It’s guaranteed that Root height is smaller than or equal to his brother’s height.

root eats a lot and his height is tripled after every year, while stoke height is doubled after every year.

After how many full years will root become strictly larger (strictly heavier) than stoke?

# EXPLANATION:

In above question stokes height is double after every year and roots height tripled after every year so we have to simply iterate a loop and after every iteration roots height multiply by 3 and stokes height multiply by 2 whenever roots height will became larger then stokes height then we will stop and print the number of iteration
lets take an example
4 7

In the first sample, root height 4 and stoke height 7 initially. After one year their heights are 4·3?=?12 and 7·2?=?14 respectively (one height is tripled while the other one is doubled). root isn’t larger than stoke yet. After the second year heights are 36 and 28, so the first height is greater than the second one. root became larger than stoke after two years so you should print 2

# SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
ll n,m,count=0;
cin>>n>>m;
while(n<=m){
n=n3;
m=m
2;
count++;
}
cout<<count;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
ll n,m,count=0;
cin>>n>>m;
while(n<=m){
n=n3;
m=m
2;
count++;
}
cout<<count;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
ll n,m,count=0;
cin>>n>>m;
while(n<=m){
n=n3;
m=m
2;
count++;
}
cout<<count;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}