Write a program to determine the center of a set of N points. For each point, we compute the distances between it and the rest N-1 points; the maximum distance is referred to as the offset of this point. Among all N points, the point with the minimum offset is the center of these points. If more points than one have the same minimum offset, output the one with the smallest x-coordinate. If they have the same x-coordinate, output the one with the smallest y-coordinate.
撰寫程式以找出一組點的中心點。您將得到一組N個點的座標 (x, y)。對於每個點,您必須計算出它到其他所有點距離中的最大值,該最大值稱為該點的偏移量。所有N個點中,偏移最小的點即為中心點。如果多點具有相同的偏移量,則中心點為x坐標最小的點。如果它們具有相同的x坐標,中心點則選擇具有最小y坐標的點。
The number of points N is a positive integer between 1 and 100. The x and y coordinates are integers between -1000 and 1000.
點的數量N是一個介於1到100之間的正整數。x 及y的坐標值是介於-1000到1000之間的整數。
The first line contains an integer N, which is the number of the points.
And each of the following N lines contains two integers x- and y-coordinates separated by a space.
第一行包含一個整數N,它是點的數量。
接下來的N行中的每行包含兩個整數x和y,代表一個點(x, y)
Output two integers x and y of the center point.
輸出兩個整數x和y,它們是中心的坐標。
3 1 5 2 6 3 7
2 6
編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
沒有發現任何「解題報告」 |