➤ Problem Link : FACVSPOW
👉 Hint : edit please
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159
#define ld long double
#define ll long long int
bool f(int n,int a)
{
ld rt=(ld)n*log(a);
ld lt=(n*log(n))-n+(0.5*log(2*pi*n));
return lt > rt;
}
ll Binary_Search(int a)
{
ll low=1;
ll high=pow(10,9);
ll mid;
while(low<high)
{
mid=low+(high-low)/2;
if(f(mid,a))
high=mid;
else
low=mid+1;
}
return low;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int a;
cin>>a;
cout<<Binary_Search(a)<<endl;
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
