### sajidhasan2021's blog

By sajidhasan2021, history, 6 weeks ago,

I was solving Div.2 114A. I have used the log function to solve this problem and repeatedly get wa for the 9th test case. I got the correct answer for that test case in codeblocks and idone but I got wrong answer for that test case in codeforces. My question is does the log function not always give the correct value or does the answer vary from compiler to compiler? Submitted code : https://codeforces.com/contest/114/submission/85798651

Thank you.

• +3

 » 6 weeks ago, # |   +27 I tried adding following function to check what's going on and the result is #include"bits/stdc++.h" using namespace std; void cmp(double x, int y) { cout << setprecision(50) << x << " " << y << " " << x - y << endl; } int main() { int n,m; cin>>n>>m; double a; a=log(m)/log(n); int b=a; // cmp(a, b); if(a==b) { cout<<"YES"< 10^{-10}$, value we will actually calculate is off by roughly$10^{-19}$if we use long doubles, so picking any epsilon in between will be fine. If on the other hand it turned out actual value can be off by e.g.$10^{-24}\$ it would mean floating points aren't enough to determine if result is an integer and we need to find some different solution