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 (是 ...
随机推荐
- 用go实现简单的冒泡排序
package main import "fmt" func main(){ var arr = [] int { 9 , 6 , 2 , 5 , 8 , 10 , 12 , 1 ...
- EOS节点远程代码执行漏洞细节
这是一个缓冲区溢出越界写漏洞 漏洞存在于在 libraries/chain/webassembly/binaryen.cpp文件的78行, Function binaryen_runtime::ins ...
- ACM1019:Least Common Multiple
Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...
- Linux Mint 使用 VNC Server (x11vnc) 进行远程屏幕
https://community.linuxmint.com/tutorial/view/2334 This tutorial was adapted from here. Remove the d ...
- Springboot启动报Multiple Dockets with the same group name are not supported. The following duplicate groups were discovered.
解决方法: 属于bean重复,根据错误提示剔除多于的Bean引用!
- 2017-2018-1 20155327 《信息安全系统设计基础》课堂测试&课下作业
2017-2018-1 20155327 <信息安全系统设计基础>课堂测试&课下作业 学习使用stat(1),并用C语言实现 提交学习stat(1)的截图 man -k ,grep ...
- 微信小程序标签页切换
WXML中: <view class="swiper-tab"> <view class="swiper-tab-list {{currentTab== ...
- LAUNCHXL-28379D入门学习-第一篇
1. 首先安装controlSUITE或者C2000ware软件,TI官网下载,安装后包括C2000的函数库和例程之类的,还可以和CCS搭配使用.controlSUITE安装完之后大约4个G,所以我安 ...
- Hibernate各种主键生成策略与配置详解(转)
原文链接:http://www.cnblogs.com/hoobey/p/5508992.html 1.assigned 主键由外部程序负责生成,在 save() 之前必须指定一个.Hibernate ...
- javaweb(十四)——JSP原理
一.什么是JSP? JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术. JSP这门技术的最大的特点在于,写jsp就像在写h ...