a083: The Center of Points 點群的中心
標籤 : Mathematics
通過比率 : 67% (2 人 / 3 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2020-04-16 08:51

內容

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
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 3.0s , <1K
隱藏 測資點#1 (50%): 3.0s , <1K
提示 :
標籤:
Mathematics
出處:
ITSA 教育部智慧創新跨域人才培育計畫 [編輯 :
zero_jason (zero_jason(MANAGER))
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」