Page 1 of 2

### Q438

Posted: Thu May 02, 2002 1:51 am
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
#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
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
It was such a silly mistake..................I got AC now,thank u very much   ### 438 - Precision Error :-?

Posted: Fri Aug 19, 2005 4:34 pm
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

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
is there any tricky case..?
i don't know why i'm getting WA..

Code: Select all

``````CUT
``````

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
u dont need to deal with equation just get the lengths of the line
and area of the triangle. simply put the values

Posted: Mon Sep 12, 2005 4:37 am
i got AC..
thanks.. ^^

### 438 WA HELP!!!!!

Posted: Sun Sep 18, 2005 4:15 pm
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){
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;
printf("%.2 lf\n", cir1);
}
else printf("0.00\n");
}
}
[/code][/list]

Posted: Wed Sep 21, 2005 4:21 pm
The probelm statement did not say that all three points will be distinct. Can your program generate correct output for cases like :

Code: Select all

``1.0 1.0 1.0 1.0 1.0 1.0``

Posted: Sat Sep 24, 2005 11:33 am
Yes it works for these inputs. But still giving WA.HELP!!!!!!!!

Posted: Sun Aug 20, 2006 1:23 pm
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
shihabrc

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

Code: Select all

``````0.0 0.0 -1.0 7.0 7.0 7.0
``````
output:

Code: Select all

``````31.42
``````

and also try to print.....

Code: Select all

`` "%.2Lf\n"``
.

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

hope that helps

Posted: Mon Mar 31, 2008 7:21 pm
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
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