ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1503. Polynomial

how you compare doubles?
Posted by Baurzhan 1 Feb 2011 09:51
Persons, who got AC without long arithmetics,tell me how did you comapre doubles? I used construction: fabs(r-l)>eps,where eps=1e-15, and i'm getting wa5 every time. Please,somebody, help me to find the bug, I need it in my work to solve polinomial of 5-th degree.My code available for looking - my judge id - 77493FG, password - shared, last submissions - 1503 problem. If somebody will find bug in my code,please write it on this thread.

Edited by author 01.02.2011 09:52
Re: how you compare doubles?
Posted by Baurzhan 6 Feb 2011 09:52
up
Re: how you compare doubles?
Posted by Baurzhan 8 Feb 2011 11:11
up, blyat,up!
Re: how you compare doubles?
Posted by hoan 10 Feb 2011 17:59
I dont use binary-search with double all in my life but i think you can use long long instead of double, and for every expresion you devide the parameter by 10^7.

like this:
double a= 1.1234567;
cout << a * 1e-1 << endl; ---> 0.11234567

you can use:
long long a= 11234567;
cout << ((long double)a * 1e-7) * 1e-1 ---> 0.11234567

I hope can help you

Edited by author 10.02.2011 17:59
Re: how you compare doubles?
Posted by Baurzhan 10 Feb 2011 20:20
thanks for advice, but it seems impossible for me to use long long because my aim is not submit 1503 problem, but care about cases when coefficients of polinomial is large enough - 10^20,10^30 - i need it in my work.Long long doesn't  allow to store such large numbers as I need. Also, I red in the forum that somobody accepted this problem with algorithm similar to mine, so my approach is correct but has some troubles with precision. Anyway, a lot of thanks for advice!