2011年10月29日 星期六

209 - Triangular Vertices


請參考下圖由點與邊所構成的三角型結構:

我們對此圖形的所有點作編號,由1開始,從上到下、由左至右依序進行編號,並選擇一些點來構成幾何圖形,例如點{1, 2, 3}與{7, 9, 18}分別構成一個三角形,{11, 13, 26, 24}與{2, 7, 9, 18}分別構成四邊形,而{4, 5, 9, 13, 12, 7}與{8, 10, 17, 21, 32, 34}分別構成六角形。

本題請你寫一個程式分別對一組點集合判斷該點集合是否可構成:三角形或四邊形或六角形,且必須滿足下列兩個條件:
  • 圖形的每一個邊必須與上圖的邊重疊。
  • 所有邊長必須相等。

Input

輸入會有多組測試資料,每組資料一列,每個點以其編號表示,且每列最多有六個點,編號的範圍介於1 ~ 32767。

Output

請參考範例資料輸出每組資料的答案,共有四種可能的情況,其中一種表示無法構成任一圖形。

Sample Input

1 2 3
11 13 29 31
26 11 13 24
4 5 9 13 12 7
1 2 3 4 5
47
11 13 23 25

Sample Output

1 2 3 are the vertices of a triangle
11 13 29 31 are not the vertices of an acceptable figure
26 11 13 24 are the vertices of a parallelogram
4 5 9 13 12 7 are the vertices of a hexagon
1 2 3 4 5 are not the vertices of an acceptable figure
47 are not the vertices of an acceptable figure
11 13 23 25 are not the vertices of an acceptable figure

原文出處

沒有留言:

張貼留言