Why WA#25???? My alg is correct 100%!!! Oh no WA#25! Please help me! var a1,a2,a3,h,s,aa,bb:real; a:array[1..3,1..2] of integer; i,l:integer; procedure readdata; begin readln(a[1,1],a[1,2],a[2,1],a[2,2]); readln(a[3,1],a[3,2],l); end; procedure writedata; begin if aa>=0 then writeln(aa:0:2) else writeln('0.00'); if bb>=0 then writeln(bb:0:2) else writeln('0.00'); end; function d(x1,y1,x2,y2:integer):real; begin d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); end; procedure square; var p:real; begin a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]); a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]); a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]); p:=(a1+a2+a3)/2; s:=sqrt(p*(p-a1)*(p-a2)*(p-a2)); end; begin readdata; square; if (a[1,1]=a[2,1]) and (a[1,2]=a[2,2]) then begin aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); bb:=aa; end else begin if (a1*a1+a2*a2<a3*a3) or (a2*a2+a3*a3<a1*a1) or (a1*a1+a3*a3<a2*a2) then begin aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]); end else begin h:=d(a[1,1],a[1,2],a[2,1],a[2,2]); aa:=s/(0.5*h); end; bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]); if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]); end; aa:=aa-l; bb:=bb-l; writedata; end. Re: Why WA#25???? My alg is correct 100%!!! Try this test: ---input -5 0 5 0 1 0 1 ---correct output 0.00 5.00 You are mistaken! No, you are mistaken correct answer is 3.00 5.00 Here is explanation: * is 0 point A B C are points. <-----A----*C---B-----> ... ... = 3.00 I dont know how you got 0.00 , please explain, maybe you are right. Edited by author 16.04.2005 23:03 see+++++++++++++ Distance from A up to B = 0 And to get up to point A and B a cord it is necessary to extend on 5.00 Re: see+++++++++++++ Can we discuss this problem via e-mail? akshinioi@yahoo.com No subject Edited by author 17.04.2005 02:15 Re: You know Russian yes i know russian language. Re: see+++++++++++++ " And to get up to point A and B a cord it is necessary to extend on 5.00 " - I agree with that. But distance between A and B isnt 0, if -5+5=0 that doesnt mean that the distance equal to nil! OR explain in details how did you get this --> "Distance from A up to B = 0 " Re: Read problem carefully! "... There is a bed of pineapples that he loves very much. The bed is a **line segment** with the ends A and B... " Point C is situated on segment AB, so there are no grounds to stretch the roap - goat anyhow can eat some pine apples, even if rope has length 0. There are infinite amount of pine apples on segment! Mail me to dkorduban[at]ukr[dot]net if you still have questions. Sorry for my English. Need help I'm sorry, I understood my mistake. When I use linear equation for this case, i got WA#3!!! I dont know why. Please help me, how to make my program to get AC? Re: Need help 1) Read this nice article (in Russian): http://g6prog.narod.ru/cgeom.rar 2) Completely rewrite your program. Try to create more general program, without dozens of special cases. That's general and very useful rule (imho) for geometrical problems. For example, there is only one special case in my program - when A = B. Of course, I can send you my AC code, if you need. Re: Why WA#25???? My alg is correct 100%!!! Thx for this test! WA #4 fixed now :) Послано Korduban [Kiev] 16 апр 2005 19:04 Try this test: ---input -5 0 5 0 1 0 1 ---correct output 0.00 5.00 Edited by author 07.11.2013 20:49 Re: Why WA#25???? My alg is correct 100%!!! Posted by adamant 22 Jan 2014 15:05 Btw, some pretty test is: 5 0 5 0 1 0 1 Correct output is 3.00 3.00 |