The Center of Gravity(一道很很簡單的幾何題)
The Center of Gravity
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2994 Accepted Submission(s): 1668
原題連結:點選開啟連結
Total Submission(s): 2994 Accepted Submission(s): 1668
原題連結:點選開啟連結
Problem Description
Everyone know the story that how Newton discovered the Universal Gravitation. One day, Newton walked
leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation.From then
on,people have sovled many problems by the the theory of the Universal Gravitation. What's more, wo also
have known every object has its Center of Gravity.
Now,you have been given the coordinates of three points of a triangle. Can you calculate the center
of gravity of the triangle?
leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation.From then
on,people have sovled many problems by the the theory of the Universal Gravitation. What's more, wo also
have known every object has its Center of Gravity.
Now,you have been given the coordinates of three points of a triangle. Can you calculate the center
of gravity of the triangle?
Input
The first line is an integer n,which is the number of test cases.
Then n lines follow. Each line has 6 numbers x1,y1,x2,y2,x3,y3,which are the coordinates of three points.
The input is terminated by n = 0.
Then n lines follow. Each line has 6 numbers x1,y1,x2,y2,x3,y3,which are the coordinates of three points.
The input is terminated by n = 0.
Output
For each case, print the coordinate, accurate up to 1 decimal places.
Sample Input
2
1.0 2.0 3.0 4.0 5.0 2.0
1.0 1.0 4.0 1.0 1.0 5.0
0
Sample Output
3.0 2.7
2.0 2.3
Source
Recommend
xhd
AC CODE:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double x[3], y[3];
int T;
while(cin >> T && T)
{
while(T--)
{
for(int i = 0; i < 3; i++)
cin >> x[i] >> y[i];
x[0] += x[1] + x[2];
y[0] += y[1] + y[2];
printf("%.1lf %.1lf\n", x[0] / 3.0, y[0] / 3.0);
}
}
return 0;
}
相關文章
- HTML很簡單?不!HTML
- Promise 其實很簡單Promise
- 離散化的一道很經典的題
- 很簡單的Flutter填小坑Flutter
- C# 一句很簡單而又很經典的程式碼C#
- 入門Flink,很簡單
- 其實泛型很簡單泛型
- 誰說 JavaScript 很簡單了?JavaScript
- 複習下 git,很簡單Git
- 一個很簡單的PHP框架lyuePHP框架
- hdu5365 簡單幾何問題
- 淘寶放大鏡的簡單實現,原來道理很簡單
- 一道簡單的題
- Redux其實很簡單(原理篇)Redux
- Kotlin:代理真的很簡單啊!Kotlin
- C語言入門很簡單pdfC語言
- Spring 測試:其實很簡單Spring
- 在windows下切換node版本,很簡單!Windows
- Android 熱修復其實很簡單Android
- hdu 1326 java (理解起來很簡單)Java
- 想作一個很簡單的HA cluster軟體
- 建立微服務很容易,但是有幾點很難 - James Hickey微服務
- pdf轉換成ppt,這樣操作很簡單
- 素數之年,IT運維其實可以很簡單運維
- PyChram社群版和商用版有何區別?這幾點很關鍵!
- 一個很簡單的演算法!! (3千字)演算法
- 這是DDD建模最難的部分(其實很簡單)
- 用java呼叫.net的wcf其實還是很簡單的Java
- 很全的 Python 面試題Python面試題
- 執行緒池其實看懂了也很簡單執行緒
- pdf線上轉換免費,這樣做很簡單!
- 在樹莓派上安裝go環境很簡單樹莓派Go
- 其實,專案管理也可以很簡單...(轉載)專案管理
- 看起來很唬人,然而卻簡單實用的CAP理論
- 聊聊一道簡單的javascript面試題JavaScript面試題
- 很全很全的JavaScript的模組講解JavaScript
- 這樣看java記憶體模型其實很簡單Java記憶體模型
- 撥開雲霧見月明—計算其實很簡單