Can someone plz help me, tell me why this solution is wrong? problem -Equivalent Numbers

#include
#include<bits/stdc++.h>
#include
using namespace std;

int main() {
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
bool flag = false;
for(int i=1;i<=100;i++)
{
for(int j=1;j<=100;j++)
{ int c=pow(a,i);
int d=pow(b,j);
if(c==d){
flag = true;
break;
}
}
}
if(flag==true){
cout<<“yes”<<endl;
}else{
cout<<“no”<<endl;
}
}
return 0;
}

You have to use double datatype to store power as int will round off the actual value
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int t;
cin >> t;
while(t–)
{
int a,b;
cin>>a>>b;

    bool flag = false;
    
    for(int i=1; i<=50; i++)
    {
        double c = pow(a,i);
        for(int j=1; j<=50; j++)
        {
            double d = pow(b,j);
            if(c==d)
            {
                flag = true;
                break;
            }
        }
    }
    
    if(flag)
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }
}

}

// also this code will give you TLE, I followed very much similar approach like yours but with vector I stored all the power of elements till 50 as constraints indicate till 10^6 , my TC was 0.6 which aint good , I think this approach is based on binary search pattern type

thanks :+1: