We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I made this way harder than it needed to be by calculating the coefficients of the quadratic equation which of course gave me overflow issues with very large numbers when multiplying very large numbers by sqrt(2). I got overflow issues as well as errors. I tried to solve those issuse until I realized that I can get a straight equation that doesn't require the multiplication of very large numbers and got the result!
the derived equation is: t=sqrt(2)*(l-sqrt(q))/abs(s1-s2) and you just need to loop through the queries!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Moving Tiles
You are viewing a single comment's thread. Return to all comments →
I made this way harder than it needed to be by calculating the coefficients of the quadratic equation which of course gave me overflow issues with very large numbers when multiplying very large numbers by sqrt(2). I got overflow issues as well as errors. I tried to solve those issuse until I realized that I can get a straight equation that doesn't require the multiplication of very large numbers and got the result! the derived equation is: t=sqrt(2)*(l-sqrt(q))/abs(s1-s2) and you just need to loop through the queries!