Page **1** of **2**

### Q438

Posted: **Thu May 02, 2002 1:51 am**

by **rmukadam**

I am using the following approach to compute the circumference:

ax^2+cy^2+dx+ey+f=0 as equa:

and center x=-d/2a y =-e/2a

a := Determinate (matrix([[X1, Y1, 1], [X2, Y2, 1], [X3, Y3, 1]]))

d := -Determinate(matrix([[X1^2+Y1^2, Y1, 1], [X2^2+Y2^2, Y2, 1], [X3^2+Y3^2, Y3, 1]]))

e := Determinate(matrix([[X1^2+Y1^2, X1, 1], [X2^2+Y2^2, X2, 1], [X3^2+Y3^2, X3, 1]]))

I'm pretty sure of the formulas and they do give me correct result. I have tested for lots of cases BUT i still get WA.......Any ideas what could be going wrong??.......Thanks.

### 438.....why am getting out put limit ex????

Posted: **Fri Aug 08, 2003 8:26 pm**

by **udvat**

#include<stdio.h>

#include<math.h>

void main()

{

double x1,x2,x3,y1,y2,y3,a,b,c;

double p,q,r,p1,q1,r1,s,L,C;

double PI=3.141592653589793L;

x1=x2=x3=y1=y2=y3=a=b=c=0;

while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3))

{

p=(x1-x2);

q=(x2-x3);

r=(x3-x1);

p1=(y1-y2);

q1=(y2-y3);

r1=(y3-y1);

a=sqrt(pow(p,2)+pow(p1,2));

b=sqrt(pow(q,2)+pow(q1,2));

c=sqrt(pow(r,2)+pow(r1,2));

s=(a+b+c)/2.0;

p=(s-a);

q=(s-b);

r=(s-c);

L=sqrt(s*p*q*r);

r=(a*b*c)/L;

r=r/4;

C=2*PI*r;

printf("%.2f\n",C);

x1=x2=x3=y1=y2=y3=a=b=c=0;

}

}

Posted: **Fri Aug 08, 2003 9:22 pm**

by **Larry**

Change:

Code: Select all

```
while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3))
```

To:

Code: Select all

```
while(6==scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3))
```

scanf returns -1 for EOF (if I recall correctly), which is non-zero, which makes this loop go forever...

### thanxxxxxxxx friend

Posted: **Fri Aug 08, 2003 10:05 pm**

by **udvat**

### 438 - Precision Error :-?

Posted: **Fri Aug 19, 2005 4:34 pm**

by **guayoyo**

Hi everybody. I think i've got an error with this problem, and I think it's a precision error, because many of my friends have solved it with in the same manner and got AC, but I got WA. If someone want to see the code, here it is:

Code: Select all

```
#include "ctype.h"
#include "math.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "stdarg.h"
#include "search.h"
#include "time.h"
#ifndef ONLINE_JUDGE
#define INPUT_NAME "data.in"
//#define OUTPUT_NAME "data.out"
#define DEBUG_NAME "debug.txt"
#endif
//abre la entrada de datos
FILE* openInput() {
#ifndef INPUT_NAME
return stdin;
#else
return fopen(INPUT_NAME, "r");
#endif
}
//abre la salida de datos
FILE* openOutput() {
#ifndef OUTPUT_NAME
return stdout;
#else
return fopen(OUTPUT_NAME, "w");
#endif
}
// abre el archivo de depuraci
```

### 438 - The Circumference of the Circle

Posted: **Sun Sep 11, 2005 1:34 pm**

by **helloneo**

is there any tricky case..?

i don't know why i'm getting WA..

line1 and line2 are calculated by given points..

and line3, line4 are evenly and vertically bisecting line1, line2

the intersecting point of line3 and line4 should be the center of the circle..

anything wrong..?

Posted: **Sun Sep 11, 2005 10:35 pm**

by **sunny**

u dont need to deal with equation just get the lengths of the line

and area of the triangle. simply put the values

: area = (l1*l2*l3)/(4*radius).

Posted: **Mon Sep 12, 2005 4:37 am**

by **helloneo**

i got AC..

thanks.. ^^

### 438 WA HELP!!!!!

Posted: **Sun Sep 18, 2005 4:15 pm**

by **shihabrc**

This program seems OK. It generated correct output for sample input. But i'm getting WA. Please help!!

[/code]

#include<stdio.h>

#include<math.h>

#define PI 3.141592653589793

void main(void){

long double k1,k2,x1,y1,x2,y2,x3,y3,rad,cir1,g,f,centx,centy,k;

while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)==6){

k1=(x3-x1)*(x3-x2)+(y3-y1)*(y3-y2);

k2=(x3-x1)*(y1-y2)+(y3-y1)*(x1-x2);

if(k2){

k=k1/k2;

g=0.5*(k*(y2-y1)-(x1+x2));

f=0.5*(k*(x1-x2)-(y1+y2));

centx=-g;

centy=-f;

rad=sqrt((centx-x1)*(centx-x1)+(centy-y1)*(centy-y1));

cir1=2*rad*PI;

printf("%.2 lf\n", cir1);

}

else printf("0.00\n");

}

}

[/code][/list]

Posted: **Wed Sep 21, 2005 4:21 pm**

by **Raiyan Kamal**

The probelm statement did not say that all three points will be distinct. Can your program generate correct output for cases like :

Posted: **Sat Sep 24, 2005 11:33 am**

by **shihabrc**

Yes it works for these inputs. But still giving WA.HELP!!!!!!!!

Posted: **Sun Aug 20, 2006 1:23 pm**

by **milacao**

The probelm statement did not say that all three points will be distinct

You're wrong. The statement says:

You are given the cartesian coordinates of three non-collinear points in the plane.

So if the three points are the same, they are obviously collinear, and they shouldn't be a valid input.

Posted: **Thu Jul 19, 2007 12:51 pm**

by **newton**

shihabrc

first try to check the sample input output in the problem carefully. if okey but WA then use forum.

try this

input:

output:

and also try to print.....

.

mind that %Lf is for long double, %lf is for double.

hope that helps

Posted: **Mon Mar 31, 2008 7:21 pm**

by **RC's**

I got 10 WAs

.. I think this problem is not very difficult.. My program produces same answer as sample input, but i don't know why I got lots of WAs..

Is it because of precision error ? Or anyone else can provide some critical test cases ?

### Re:

Posted: **Tue Apr 01, 2008 8:21 pm**

by **emotional blind**

RC's wrote:
Is it because of precision error ?

Not sure, but It could be. What is your value of pi? I defined it as 3.141592653589793