Help me in solving FODCHAIN problem

My issue

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

int main() {
// your code goes here
int t; cin>>t;
while(t–)
{
long long int a,b; cin>>a>>b;
double ansa = log(a);
double ansb = log(b);
ansa = ansa/ansb;
long long int ans = ansa + 1;
cout<<ans<<endl;

   //long long int ans = 0;
   //while(a>0)
   //{
   //    ans++;
   //    a = a/b;
   //}
   //cout<<ans<<endl;
}
return 0;

}

why my this code is not working while the other code in the comments is getting passed…what is the mistake occurring with the log function…Please help

My code

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

int main() {
	// your code goes here
	int t; cin>>t;
	while(t--)
	{
	    long long int a,b; cin>>a>>b;
	    double ansa = log(a);
	    double ansb = log(b);
	    ansa = ansa/ansb;
	    long long int ans = ansa + 1;
	    cout<<ans<<endl;
	    
	    
	   //long long int ans = 0;
	   //while(a>0)
	   //{
	   //    ans++;
	   //    a = a/b;
	   //}
	   //cout<<ans<<endl;
	}
	return 0;
}

Problem Link: FODCHAIN Problem - CodeChef

@siddesh_11
Your logic is not right.
Plzz refer my solution for better understanding of the logic.

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n,a;
	    cin>>n>>a;
	    int ans=0;
	    while(n>0)
	    {
	        ans++;
	        n/=a;
	    }
	  cout<<ans<<endl;
	}
	return 0;
}

Just look at the commented code I have implemented in that way also and yes it works but i just wanted to know as it is indirectly taking the log of E with base K and then adding one to it just to get the answer as expected as the levels are starting from 1…so why is it giving WA…on which test case…

@siddesh_11
your code is failing for this test case
1
1000000000 10
answer should be 10 your code it printing 9

@dpcoder_007
thank you very much…I really appreciate the effort…
Just one more thing…

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

int main() {
// your code goes here
int t; cin>>t;
while(t–)
{
long long int a,b; cin>>a>>b;
double ansa = log(a);
double ansb = log(b);
cout<<"ansa: "<<ansa<<endl;
cout<<"ansb: "<<ansb<<endl;
ansa = ansa/ansb;
cout<<ansa<<endl;
/*
For Testcase 1000000000 10
Till here ansa = 9 which is correct
but after that ans is not getting the value 10 even after incrementing…
*/

    long long int ans = (int)(ansa + 1);
   
    cout<<ans<<endl;   // ans = 9 .....why this is not getting incremented
    
   //long long int ans = 0;
   //while(a>0)
   //{
   //    ans++;
   //    a = a/b;
   //}
   //cout<<ans<<endl;
}
return 0;

}
on printing the value of ansa it is still giving 9 which it should give but according to the logic when it is incremented by 1… it is not getting incremented…it is still 9…how and why is this possible…?