UVA-10242 - Fourth Point !!
18 Apr 2018
- UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt。
- 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
- 本題選為「20161220 / 20101223 大學程式能力檢定 CPE」題目。
- 相同題目:NCTU-10566
題意概要
題目將給定平行四邊形的兩條邊的頂點座標,根據已知的頂點求第四個頂點的座標。
- 分析:本題為簡單的數學題,利用平行四邊形的特性:「對角線頂點座標和要相同」,即:若已知平行四邊形其中三個點頂分別為 、、,其中 和 為該平行四邊形的對角線頂點,則 且 ,利用此性質即可解。唯獨要注意的是,本題輸出格式為「小數點要三位的浮點數」。
Input
Each line of input contains eight floating point numbers: the coordinates of one of the endpoints of the first side followed by the coordinates of the other endpoint of the first side, followed by the coordinates of one of the endpoints of the second side followed by the coordinates of the other endpoint of the second side. All coordinates are in meters, to the nearest mm. All coordinates are between and . Input is terminated by end of file.
Output
For each line of input, print the coordinates of the fourth point of the parallelogram in meters, to the nearest mm, separated by a single space.
Sample Input
0.000 0.000 0.000 1.000 0.000 1.000 1.000 1.000
1.000 0.000 3.500 3.500 3.500 3.500 0.000 1.000
1.866 0.000 3.127 3.543 3.127 3.543 1.412 3.145
Sample Output
1.000 0.000
-2.500 -2.500
0.151 -0.398