|
|
The only formulas you need is a distance between two points to find the answer and a distance between point and a line to check if answer exists Don't use double or you will suck hard. My formulas are definitely correct (because I got AC), but with double and framework functions like Math.Sqrt I was getting very big inaccuracies (about FEW degrees for angles between tangent and shots). Then I switched to BigInteger and got AC immediately. Edited by author 19.11.2020 04:59 I am checking possibility of shot, I am checking edge case (when shot just touches the tank). My geometry calculations use epsilon (also tried to adjust epsilon, didn't help). Tried to output results with 7 decimals. I am using double. What else I could miss? Are you sure that the size of your epsilon is enough? The angle might be too small. Place the tank and players on opposite sides of the map, and check your solution. Edited by author 23.10.2020 13:36 use double for ALL variables Test 9 is about the possibility of the shoot. For example I just changed < on <=: if (4 * (pow(x1 - xc, 2) + pow(y1 - yc, 2) - pow(r, 2)) <= pow(x2 - x1, 2) + pow(y2 - y1, 2)) { I calculated two points of intersection from line that go through two points((x_mid, y_mid) and (x_circle,y_circle)) and then picked nearest two given two points.But this gives me WA3. What should i do? You need to check the possibility of a shot. The enemy may be out of your sight. Подумайте о пересечение прямой из данных двух точек с окружностью а потом о треугольниках Edited by author 16.02.2020 19:45 И ни в коем случае не думайте о зебрах Somebody had this test case? Try this tests: 0 0 5 -5 100 -5 -100 ans: No way 0 0 5 5 100 5 -100 ans: No way 0 0 100 5 100 -5 100 ans: No way 0 0 100 5 -100 -5 -100 ans: No way |
|
|