HDU 2105 The Center of Gravity
http://acm.hdu.edu.cn/showproblem.php?pid=2105
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?
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.
代码:
#include <bits/stdc++.h>
using namespace std; int main() {
int n;
while(~scanf("%d", &n)) {
if(n == 0) break;
for(int i = 1; i <= n; i ++) {
double x1, y1, x2, y2, x3, y3;
cin>> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
double x = 0, y = 0;
x = 1.0 * (x1 + x2 + x3) / 3;
y = 1.0 * (y1 + y2 + y3) / 3;
printf("%.1lf %.1lf\n", x, y);
}
}
return 0;
}
HDU 2105 The Center of Gravity的更多相关文章
- hdu 2105:The Center of Gravity(计算几何,求三角形重心)
The Center of Gravity Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 2105 The Center of Gravity (数学)
题目链接 Problem Description Everyone know the story that how Newton discovered the Universal Gravitatio ...
- hdu 2105
#include <iostream> #include <stdio.h> using namespace std; int main() { double a,b,c,d, ...
- fzu 1330:Center of Gravity(计算几何,求扇形重心)
Problem 1330 Center of Gravity Accept: 443 Submit: 830Time Limit: 1000 mSec Memory Limit : 327 ...
- Android android:gravity属性介绍及效果图
转自: http://blog.csdn.net/aminfo/article/details/7784229 Android:gravity的属性官方说明如下: public static fina ...
- 从零开始学android开发-布局中 layout_gravity、gravity、orientation、layout_weight
线性布局中,有 4 个及其重要的参数,直接决定元素的布局和位置,这四个参数是 android:layout_gravity ( 是本元素相对于父元素的重力方向 ) android:gravity (是 ...
- Android中的layout_gravity和gravity的区别
在Android的布局中,除了padding和margin容易弄混之外,还有layout_gravity和gravity.按照字面意思来说,layout_gravity就是相对于layout来设置的. ...
- 【整理】Android中的gravity和layout_gravity区别
[背景] 在Android中,想要设置个按钮的水平对齐,都累死了: [已解决]ADT中已设置TableLayout布局的情况下如何设置按钮居中对齐 所以现在有必要搞清楚,到底gravity和la ...
- android 布局中 layout_gravity、gravity、orientation、layout_weight
线性布局中,有 4 个及其重要的参数,直接决定元素的布局和位置,这四个参数是 android:layout_gravity ( 是本元素相对于父元素的重力方向 ) android:gravity (是 ...
随机推荐
- CTF-安恒19年一月月赛部分writeup
CTF-安恒19年一月月赛部分writeup MISC1-赢战2019 是一道图片隐写题 linux下可以正常打开图片,首先到binwalk分析一下. 里面有东西,foremost分离一下 有一张二维 ...
- www.pantom.top
新建小站 https://www.pantom.top
- Selenium_python自动化跨浏览器执行测试(简单多线程案例)
发生背景: 跨浏览器测试是功能测试的一个分支,用以验证web应用在不同浏览器上的正常工作,通常情况下,我们都期望web类应用能够被我们的用户在任何浏览器上使用,例如有的人喜欢IE浏览器上使用,有的人喜 ...
- 嵌入式Linux系统移植——uboot常用命令
flash的一般分区: 其它数据 环境变量 可执行程序.如bootloader print(可缩写为:pri):打印查看uboot这个软件中集成的环境变量setenv.saveenv:设置.保存环境变 ...
- 2016-2017-2 20155338 实验二《Java面向对象程序设计》实验报告
2016-2017-2 20155338 实验二<Java面向对象程序设计>实验报告 实验内容: 1.初步掌握单元测试和TDD 2.理解并掌握面向对象三要素:封装.继承.多态 3.初步掌握 ...
- sort与qsort的异同
主要内容: 1.qsort的用法 2.sort的用法 3.qsort和sort的区别 qsort的用法: 原 型: void qsort(void *base, int nelem, int widt ...
- Easyui 控件的初始化方法
问题: Easyui的控件在初始化的时候有两种方式: 页面指定class属性 js里初始化该id为easyui的控件 那么问题是: 如果页面不指定class属性,只是使用js初始化的话,会导致无法用控 ...
- BZOJ2039_employ人员雇佣_KEY
题目传送门 网络流,求最小割. 设tot为所有盈利的和,即所有人(不花钱)雇佣. 对于S->i建一条容量为c[i]的边,i->j建一条S[i][j]*2的边,之所以这样建是因为如果不选这个 ...
- 如何在存储过程的IN操作中传递字符串变量
原始SQL如下: SELECT MONTH(OrderTime) AS datetype, SUM(DeliveryCount) AS decount, Region FROM (SELECT dbo ...
- DataTable保存与读取 stream
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...