我想知道是我理解錯誤還是答案錯...
求各位大神幫幫www
測資二是
16 1 15 6
x1 = 16 y1 = 2 x2 = 15 y2 = 6
算出來的距離應該是 5.0990
測資不知道幾是
18 41 44 39
x1 = 18 y1 = 41 x2 = 44 y2 = 39
距離應該是 26.0768
我的程式碼長這樣= =
我想知道是我理解錯誤還是答案錯...
求各位大神幫幫www
測資二是
16 1 15 6
x1 = 16 y1 = 2 x2 = 15 y2 = 6
算出來的距離應該是 5.0990
測資不知道幾是
18 41 44 39
x1 = 18 y1 = 41 x2 = 44 y2 = 39
距離應該是 26.0768
我的程式碼長這樣= =
n, m = map(int, input().split())students = list(map(int, input().split()))min = 9999for i in range(0, m * 2 - 2, 2):x1 = students[i]y1 = students[i + 1]x2 = students[i + 2]y2 = students[i + 3]ps = round((((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5, 4)if min > ps:min = ps
print('%.4f' %(min))
後來發現是我自己的問題,重新看了題目後修改就AC了www
Finally, 附上Python 程式碼~~~