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 1119. Metro

tiancaihb If you like using printf,pay attention to this! [1] // Problem 1119. Metro 11 Aug 2009 11:00
I thought my algo is all right but got wa3&5.
Why?
Because I saw this in the statement: rounded to the integer
So,I wrote printf("%.0lf",a+0.49999999);
But it seemed to be wrong.
I checked again and again,finally I found the problem:
When you use %x.ylf,where x and y are numbers,the result is automatically rounded.
However,when using (int)a,it means FLOOR.
So,if you want to write rounded ans,there are 2 ways:
    printf("%d",(int)(a+0.499999999));
or  printf("%.0lf",a);
Nice! Now it works, thank you :0