190 - Circle Through Three Points

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

artless
New poster
Posts: 7
Joined: Tue Nov 22, 2011 2:01 pm

please help me .....Why i got WA to 190?

Post by artless »

:roll:
#include<stdio.h>
#include<math.h>
int main()
{
double x1,x2,x3,y1,y2,y3,a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,D,g,f,c,G,F,r;
while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)
{a1=2*x1;
a2=2*x2;
a3=2*x3;
b1=2*y1;
b2=2*y2;
b3=2*y3;
c1=c2=c3=1.0;
d1=(x1*x1)+(y1*y1);
d2=(x2*x2)+(y2*y2);
d3=(x3*x3)+(y3*y3);
// slove of 3 equations having 3 variable a*g+b*f+c=0
D=(a1*b2*c3+b1*a3*c2+c1*a2*b3)-(a1*c2*b3+b1*a2*c3+c1*b2*a3);
g=((b1*c3*d2+c1*b2*d3+d1*c2*b3)-(b1*c2*d3+c1*b3*d2+d1*b2*c3))/D;
f=((a1*c2*d3+c1*a3*d2+d1*a2*c3)-(a1*c3*d2+c1*a2*d3+d1*c2*a3))/D;
c=((a1*b3*d2+b1*a2*d3+d1*b2*a3)-(a1*b2*d3+b1*a3*d2+d1*a2*b3))/D;
G=2.0*g;
F=2.0*f;
r=sqrt(g*g+f*f-c);

printf("(x ");if(g<0) printf("- %.3lf)^2 + (y ",-g);
else if(g>=0)printf("+ %.3lf)^2 + (y ",g);
if(f<0) printf("- %.3lf)^2 = %.3lf^2\n",-f,r);
else if(f>=0) printf("+ %.3lf)^2 = %.3lf^2\n",f,r);
printf("x^2 + y^2 ");
if(G<0)printf("- %.3lfx ",-G);
else if(G>=0)printf("+ %.3lfx ",G);
if(F<0)printf("- %.3lfy ",-F);
else if(F>=0)printf("+ %.3lfy ",F);
if(c<0)printf("- %.3lf = 0\n",-c);
else if(c>=0)printf("+ %.3lf =0\n",c);
}
return 0;
}
artless
New poster
Posts: 7
Joined: Tue Nov 22, 2011 2:01 pm

why wa ........190...........????????????

Post by artless »

#include<stdio.h>
#include<math.h>
int main()
{
double x1,x2,x3,y1,y2,y3,a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,D,g,f,c,G,F,r;
while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)
{a1=2.0*x1; a2=2.0*x2; a3=2.0*x3;
b1=2.0*y1; b2=2.0*y2; b3=2.0*y3;
c1=c2=c3=1.0;
d1=(x1*x1)+(y1*y1); d2=(x2*x2)+(y2*y2); d3=(x3*x3)+(y3*y3);

D=(a1*b2*c3+b1*a3*c2+c1*a2*b3)-(a1*c2*b3+b1*a2*c3+c1*b2*a3);
g=((b1*c3*d2+c1*b2*d3+d1*c2*b3)-(b1*c2*d3+c1*b3*d2+d1*b2*c3))/D;
f=((a1*c2*d3+c1*a3*d2+d1*a2*c3)-(a1*c3*d2+c1*a2*d3+d1*c2*a3))/D;
c=((a1*b3*d2+b1*a2*d3+d1*b2*a3)-(a1*b2*d3+b1*a3*d2+d1*a2*b3))/D;
G=2.0*g;
F=2.0*f;
r=sqrt(g*g+f*f-c);

printf("(x ");if(g<0) printf("- %.3lf)^2 + (y ",-g);
else if(g>=0)printf("+ %.3lf)^2 + (y ",g);
if(f<0) printf("- %.3lf)^2 = %.3lf^2\n",-f,r);
else if(f>=0) printf("+ %.3lf)^2 = %.3lf^2\n",f,r);
printf("x^2 + y^2 ");
if(G<0)printf("- %.3lfx ",-G);
else if(G>=0)printf("+ %.3lfx ",G);
if(F<0)printf("- %.3lfy ",-F);
else if(F>=0)printf("+ %.3lfy ",F);
if(c<0)printf("- %.3lf = 0\n",-c);
else if(c>=0)printf("+ %.3lf = 0\n",c);
}
return 0;
}
Neto_o
New poster
Posts: 2
Joined: Wed Dec 28, 2011 9:21 pm

Re: please help me .....Why i got WA to 190?

Post by Neto_o »

I'm not reading your code since it's not written with the needed spaces and indentation, I can give you some inputs/outputs from my Accepted code, so you can test:

Input:

Code: Select all

-34 23 -18 16 20 15
0 0 0 12 12 0
0 12 0 0 12 0
-143 200 -143 -100 200 200
0 0 0.0134 0.0325 0.0888 0.087787
0 0 0.00134 0.00325 0.0888 0.0087787
-42350 -800 0 0 4235 -800

Output:

Code: Select all

(x - 2.840)^2 + (y - 85.420)^2 = 72.481^2
x^2 + y^2 - 5.680x - 170.840y + 2051.200 = 0

(x - 6.000)^2 + (y - 6.000)^2 = 8.485^2
x^2 + y^2 - 12.000x - 12.000y + 0.000 = 0

(x - 6.000)^2 + (y - 6.000)^2 = 8.485^2
x^2 + y^2 - 12.000x - 12.000y + 0.000 = 0

(x - 28.500)^2 + (y - 50.000)^2 = 227.843^2
x^2 + y^2 - 57.000x - 100.000y - 48600.000 = 0

(x - 0.116)^2 + (y + 0.029)^2 = 0.120^2
x^2 + y^2 - 0.233x + 0.058y + 0.000 = 0

(x - 0.047)^2 + (y + 0.017)^2 = 0.050^2
x^2 + y^2 - 0.093x + 0.035y + 0.000 = 0

(x + 19057.500)^2 + (y + 112495.156)^2 = 114097.978^2
x^2 + y^2 + 38115.000x + 224990.312y + 0.000 = 0

artless
New poster
Posts: 7
Joined: Tue Nov 22, 2011 2:01 pm

Re: please help me .....Why i got WA to 190?

Post by artless »

thank you... i got AC
pecijackson
New poster
Posts: 3
Joined: Tue Jan 31, 2012 7:05 am

Re: 190 WA

Post by pecijackson »

i did't see anything wrong bout your codes sir.try to rewrite the codes. if it's doesn't work. i'll re-write the codes for you
S.H.Bouwhuis
New poster
Posts: 13
Joined: Fri Apr 27, 2007 12:03 pm
Location: The Netherlands

Re: 190 WA

Post by S.H.Bouwhuis »

Here are some sample inputs and outputs for my accepted submission:

Input

Code: Select all

7.0 -5.0 -1.0 1.0 0.0 -6.0
1.0 7.0 8.0 6.0 7.0 -2.0
5 5 4 7 16 5
56 40 66 76 31 8
44 39 26 23 37 38
18 82 29 41 33 15
0 49 19 56 98 3
7 0 11 0 9 2
0 9 0 15 3 12
0.0 0.0 1.0 0.0 0.0 2.0
6.6  2.5 -4.0 -4.0  6.6 -8.0
3.7 -4.1  3.7 -1.5  1.0  1.0
9.0 -2.0  1.0  1.0 -5.0 -2.0
5.4  6.3  0.0  6.3 -7.8 -0.8
3.1  4.1  5.9  2.6  5.3  5.8
10.0 11.0 12.0 13.0  0.0  0.0
0.0 0.0 1.1 0.0 0.0 1.1
Output

Code: Select all

(x - 3.000)^2 + (y + 2.000)^2 = 5.000^2
x^2 + y^2 - 6.000x + 4.000y - 12.000 = 0

(x - 3.921)^2 + (y - 2.447)^2 = 5.409^2
x^2 + y^2 - 7.842x - 4.895y - 7.895 = 0

(x - 10.500)^2 + (y - 9.000)^2 = 6.801^2
x^2 + y^2 - 21.000x - 18.000y + 145.000 = 0

(x + 33.686)^2 + (y - 84.302)^2 = 100.031^2
x^2 + y^2 + 67.372x - 168.603y - 1764.717 = 0

(x - 42.830)^2 + (y - 22.191)^2 = 16.849^2
x^2 + y^2 - 85.660x - 44.383y + 2042.957 = 0

(x + 279.295)^2 + (y + 19.738)^2 = 314.221^2
x^2 + y^2 + 558.590x + 39.475y - 20339.607 = 0

(x - 32.340)^2 + (y + 9.494)^2 = 66.838^2
x^2 + y^2 - 64.679x + 18.987y - 3331.372 = 0

(x - 9.000)^2 + y^2 = 2.000^2
x^2 + y^2 - 18.000x + 77.000 = 0

x^2 + (y - 12.000)^2 = 3.000^2
x^2 + y^2 - 24.000y + 135.000 = 0

(x - 0.500)^2 + (y - 1.000)^2 = 1.118^2
x^2 + y^2 - 1.000x - 2.000y = 0

(x - 2.526)^2 + (y + 2.750)^2 = 6.645^2
x^2 + y^2 - 5.053x + 5.500y - 30.211 = 0

(x + 0.011)^2 + (y + 2.800)^2 = 3.932^2
x^2 + y^2 + 0.022x + 5.600y - 7.622 = 0

(x - 2.000)^2 + (y + 8.500)^2 = 9.552^2
x^2 + y^2 - 4.000x + 17.000y - 15.000 = 0

(x - 2.700)^2 + (y + 4.501)^2 = 11.133^2
x^2 + y^2 - 5.400x + 9.001y - 96.399 = 0

(x - 4.883)^2 + (y - 4.066)^2 = 1.784^2
x^2 + y^2 - 9.767x - 8.131y + 37.195 = 0

(x - 142.500)^2 + (y + 119.500)^2 = 185.974^2
x^2 + y^2 - 285.000x + 239.000y = 0

(x - 0.550)^2 + (y - 0.550)^2 = 0.778^2
x^2 + y^2 - 1.100x - 1.100y = 0
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
emranbuet2002
New poster
Posts: 4
Joined: Sun Nov 11, 2012 2:37 am

Re: 190 WA

Post by emranbuet2002 »

Code: Select all

Removed after accepted!
Last edited by emranbuet2002 on Wed Nov 21, 2012 4:58 am, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 190 WA

Post by brianfry713 »

Print a single blank line after each equation pair including the last one.
Check input and AC output for thousands of problems on uDebug!
emranbuet2002
New poster
Posts: 4
Joined: Sun Nov 11, 2012 2:37 am

Re: 190 WA

Post by emranbuet2002 »

Thanks!
laituanksa245
New poster
Posts: 20
Joined: Tue Jan 10, 2012 4:23 pm
Location: Vietnam

190 WA Help plz

Post by laituanksa245 »

I have tried all the test cases posted in this forum, but i still got WA.
Help me please. I feel so frustrated

Code: Select all

Code Removed
AC :P
Last edited by laituanksa245 on Mon Dec 03, 2012 5:14 am, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 190 WA Help plz

Post by brianfry713 »

Check the sample I/O, you're printing extra spaces.
Check input and AC output for thousands of problems on uDebug!
laituanksa245
New poster
Posts: 20
Joined: Tue Jan 10, 2012 4:23 pm
Location: Vietnam

Re: 190 WA Help plz

Post by laituanksa245 »

Thank you so much.
You have helped me AC so many problems
alimbubt
New poster
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh
Contact:

Re: 190 WA Help plz

Post by alimbubt »

Code: Select all

This is very easy problem...Just follow the process...

(1)try to make three equation with three coordinates.
(2)then try to find the value of unknown three variables with the process of determinant.
(3)be careful what the statement says "Plus, minus, and equal signs must be separated from the adjacent characters by a single space on each side."

Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
mahade hasan
Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

Re: 190 WA Help plz

Post by mahade hasan »

ACCCC
we r surrounded by happiness
need eyes to feel it!
?????
New poster
Posts: 1
Joined: Sat Apr 12, 2014 8:05 am

help please

Post by ????? »

what is my problem in this prob i cant find help please

#include<stdio.h>
#include<math.h>
#include<string.h>
void p(double x,double y,double temp,double ax,double ay)
{ :evil: :evil: :evil:
if(x==0)
{
printf("x^2 + ");
}
else if(x<0)
{
printf("(x + %0.3lf)^2 + ",(x*(-1)));
}
else if(x>0)
{
printf("(x - %0.3lf)^2 + ",x);
}
if(y==0)
{
printf("y^2 = %0.3lf^2\n",temp);
}
else if(y<0)
{
printf("(y + %0.3lf)^2 = %0.3lf^2\n",(y*(-1)),temp);
}
else if(y>0)
{
printf("(y - %0.3lf)^2 = %0.3lf^2\n",y,temp);
}
temp=pow(x,2)+pow(y,2)-pow(temp,2);
printf("x^2 + y^2 ");
if(x<0)
{
printf("+ %0.3lfx ",(x*(-2)));
}
else if(x>0)
{
printf("- %0.3lfx ",(x*2));
}
if(y<0)
{
printf("+ %0.3lfy ",(y*(-2)));
}
else if(y>0)
{
printf("- %0.3lfy ",(y*2));
}

if(temp<=0)
{
printf("- %0.3lf ",(temp*(-1)));
}
else if(temp>0)
{
printf("+ %0.3lf ",temp);
}
printf("= 0\n");
return ;
}
void britto(double ax,double ay,double bx,double by,double cx,double cy)
{
double temp1,temp2,temp3,temp4,temp,x,y,ax1,ay1,bx1,by1,cx1,cy1;
ax1=pow(ax,2);
ay1=pow(ay,2);
bx1=pow(bx,2);
by1=pow(by,2);
cx1=pow(cx,2);
cy1=pow(cy,2);
temp1=(((bx1+by1-cx1-cy1)*(ay-by)*(-1))/2);
temp2=((ax1+ay1-bx1-by1)*(by-cy))/2;
temp3=((ax1+ay1-bx1-by1)*(bx-cx)*(-1))/2;
temp4=((bx1+by1-cx1-cy1)*(ax-bx))/2;
temp=((ax-bx)*(by-cy)) -((ay-by)*(bx-cx));
x=(temp1+temp2)/(temp);
y=(temp3+temp4)/(temp);
temp1=pow((x-ax),2);
temp2=pow((y-ay),2);
temp=sqrt((temp1+temp2));
p(x,y,temp,ax,ay);
return ;
}
int main()
{
double ax,ay,bx,by,cx,cy;
for( ;(scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy))==6;)
{
britto(ax,ay,bx,by,cx,cy);
}

return 0;
}
Post Reply

Return to “Volume 1 (100-199)”