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 1258. Pool

this is really shitty....this program compiles just fine with gcc3.2 why do I get CE
Posted by Fechete Dan Ionut[dany] 3 Oct 2004 22:17
#include <stdio.h>
#include <math.h>

int i,j,n,m,k;
int w,d;


int main()
{
    int x0,y0,x1,y1;
    scanf ("%d%d%d%d%d%d",&w,&d,&x0,&y0,&x1,&y1);
    char c[10000];
    scanf ("%s",c);
    for (i=0;c[i];i++)
     {
     if (c[i]=='F') y0=-y0;
     if (c[i]=='L') x0=-x0;
     if (c[i]=='B') y0=d+d-y0;
     if (c[i]=='R') x0=w+w-x0;
     }
    double dist=sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));

    printf ("%.4lf\n",dist);

    return 0;
}
Re: this is really shitty....this program compiles just fine with gcc3.2 why do I get CE
Posted by Vladimir Yakovlev (USU) 3 Oct 2004 23:16
You must replace

sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));

with

sqrt((double)((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)));