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 1316. Electronic Auction

WA6: use this stupid code for correct input
Posted by dgorlov 23 Aug 2006 18:49
i have WA6
for correct input of price
use procedure like this
int        read_price(void) {
    double f;
    fscanf(inf,"%lf",&f);
    return (int)((f+1e-9)*100.0);
}
and you got AC
Re: WA6: use this stupid code for correct input
Posted by Lion 5 Jan 2007 13:30
Thank you very much!I got AC
Re: WA6: use this stupid code for correct input
Posted by Integral 7 Oct 2013 03:17
Can you explain me please when expressions (int) (f * 100) and (int)((f+1e-9)*100.0)can differ. (I got AC after using this method, but still can't figure out what  the problem is).
Thanks in advance :)

Edited by author 07.10.2013 03:17
Re: WA6: use this stupid code for correct input
Posted by Manciu Ion 4 Dec 2017 16:00
I don't understand !
Why when I read data like integer before and after point :

int price = before * 100 + after -> is wa6

and when I read data like double:

double d;
scanf("%lf, &d);
int price =  (int)(d * 100.0 + 0.1) -> is ok