|
|
вернуться в форумWhat's Test 56?I got wrong so many times!Can anybody tell me why Послано yessit 19 дек 2006 15:22 Const Zero=1E-9; Var a, b, c, d, r, cx, cy, cz, sx, sy, sz, nx, ny, nz, vx, vy, vz: Double; Procedure Taxis(t:Double); Var mx, my, mz: Double; Begin If t < 0 Then Exit; mx := sx + vx * t; my := sy + vy * t; mz := sz + vz * t - 5 * sqr(t); If Sqr(mx - cx) + Sqr(my - cy) + Sqr(mz - cz) < Sqr(r) Then Begin WriteLn('HIT'); Halt; End; End; Begin Read(cx, cy, cz, nx, ny, nz, r, sx, sy, sz, vx, vy, vz); a := -5 * nz; b := vx * nx + vy * ny + vz * nz; c := (sx - cx) * nx + (sy - cy) * ny + (sz - cz) * nz; If Abs(a) < Zero Then If Abs(b) < Zero then Begin If Abs(c) < Zero Then Begin writeln('HIT'); Halt; End; End Else Taxis(-c / b) Else Begin d := Sqr(b) - 4 * a * c; If (d >= 0) or (Abs(d) < 1E-16) Then Begin d := Sqrt(d); Taxis((-b - d) / 2 / a); Taxis((-b + d) / 2 / a); End; End; WriteLn('MISSED'); End. Re: What's Test 56?I got wrong so many times!Can anybody tell me why Read rule 5: To hit the dartboard the dart should hit it strictly inside boundary from any side. This is your mistake. Check the conditions of hit in your code one more time. Good luck! Re: What's Test 56?I got wrong so many times!Can anybody tell me why Послано yessit 19 дек 2006 16:24 Thank you vary much! I got Accepted. Re: What's Test 56?I got wrong so many times!Can anybody tell me why Послано SPIRiT 29 дек 2006 18:08 To Sandro(USU): Well, well it seems to me that there is a little bit of misunderstanding. First I thought that if the dart trajectory belongs to the plane (and that's exactly the test 56), it can be a hit, if it crosses the circle. Turns out not, in that case it's always MISSED... I do agree that such way the problem is easy to solve. But it can become much tougher, if you change the statement a little bit - to check if the dart crosses the circle, IF the dart is on the plane (infinite number of points). In that case you will have to solve the polinomial not of the 2-nd, but of the 4-th degree (a much more formidable task)... Such a test would be a nice one. I understand that it may not be compatible with the statement for someone, but it would become then a really good problem even for sophisticated programmers... Edited by author 29.12.2006 18:30 Edited by author 29.12.2006 18:30 Re: What's Test 56?I got wrong so many times!Can anybody tell me why To SPIRiT: The problem statement is OK for test 56. If you change the statement it will be another problem. It's better to save this problem and make a new one about intersection parabola and circle. You can do it. :) |
|
|