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 1800. Murphy's Law

WA#15
Posted by SpartakusMd 11 Mar 2012 00:28
Where is the error in my code?
Please, help...

#include <stdio.h>
#include <conio.h>
#include <math.h>

int main() {
    float l, h, w, n, t;

    scanf("%f%f%f", &l, &h, &w);

    h /= 100;
    l /= 100;
    w /= 60;

        h -= l/2;
        t = sqrt(2*h/9.81);
        n = t*w;
        n -= (int) n;
        if(n <= 0.25 || n >= 0.75) printf("butter");
        else printf("bread");


    return 0;
}
Re: WA#15
Posted by falicos 12 Mar 2012 23:56
The first change float to  double and respectivly change scanf like this
 double l, h, w, n, t;

    scanf("%lf%lf%lf", &l, &h, &w);
and add the case
if( l/2>h ){
printf("butter");
return 0;
}
and your  get AC
Re: WA#15
Posted by falicos 13 Mar 2012 00:01
Sorry I didnot sea that your allready  have AC on this problem 20:49:45
12 мар 2012
Re: WA#15
Posted by SpartakusMd 14 Mar 2012 22:36
Thanks