My issue
do not know how to appraoch this type of problem
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int x,y;
cin>>x>>y;
int operation=0;
while(x<2*y && y<2*x){
//jb x greater so what we have to do is either x decreses of y is incerase
if(x>y){
// y is incerase
if(y+1<=2*x)y++;
else x--;
}
else{
if(x+1>=2*y)x++;
else y--;
}
operation++;
}
cout<<operation<<endl;
}
return 0;
}
Problem Link: Ratio By 2 Practice Coding Problem