hdu 1115 Lifting the Stone 多边形的重心
Lifting the Stone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
4
5 0
0 5
-5 0
0 -5
4
1 1
11 1
11 11
1 11
6.00 6.00
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<bitset>
#include<set>
#include<map>
#include<time.h>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-8
#define bug(x) cout<<"bug"<<x<<endl;
const int N=1e5+,M=1e6+,inf=1e9+;
const LL INF=1e18+,mod=1e9+; struct Point
{
double x, y ;
} p[M];
int n ;
double Area( Point p0, Point p1, Point p2 )
{
double area = ;
area = p0.x * p1.y + p1.x * p2.y + p2.x * p0.y - p1.x * p0.y - p2.x * p1.y - p0.x * p2.y;// 求三角形面积公式
return area / ; //另外在求解的过程中,不需要考虑点的输入顺序是顺时针还是逆时针,相除后就抵消了。
}
pair<double,double> xjhz()
{
double sum_x = ,sum_y = ,sum_area = ;
for ( int i = ; i < n ; i++ )
{
double area = Area(p[],p[i-],p[i]) ;
sum_area += area ;
sum_x += (p[].x + p[i-].x + p[i].x) * area ;
sum_y += (p[].y + p[i-].y + p[i].y) * area ;
}
return make_pair(sum_x / sum_area / , sum_y / sum_area / ) ;
}
int main ()
{
int T;
scanf ( "%d", &T ) ;
while ( T -- )
{
scanf ( "%d", &n ) ;
for(int i=; i<n; i++)
scanf ( "%lf%lf", &p[i].x, &p[i].y ) ;
pair<double,double> ans=xjhz();
printf("%.2f %.2f\n",ans.first,ans.second);
}
return ;
}
hdu 1115 Lifting the Stone 多边形的重心的更多相关文章
- hdu 1115:Lifting the Stone(计算几何,求多边形重心。 过年好!)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 1115 Lifting the Stone
题目链接:hdu 1115 计算几何求多边形的重心,弄清算法后就是裸题了,这儿有篇博客写得很不错的: 计算几何-多边形的重心 代码如下: #include<cstdio> #include ...
- hdu 1115 Lifting the Stone (数学几何)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- poj 1115 Lifting the Stone 计算多边形的中心
Lifting the Stone Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- Lifting the Stone(多边形重心)
Lifting the Stone Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- POJ1385 Lifting the Stone 多边形重心
POJ1385 给定n个顶点 顺序连成多边形 求重心 n<=1e+6 比较裸的重心问题 没有特别数据 由于答案保留两位小数四舍五入 需要+0.0005消除误差 #include<iostr ...
- Hdoj 1115.Lifting the Stone 题解
Problem Description There are many secret openings in the floor which are covered by a big heavy sto ...
- hdu1115 Lifting the Stone(几何,求多边形重心模板题)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...
- (hdu step 7.1.3)Lifting the Stone(求凸多边形的重心)
题目: Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
随机推荐
- nvidia-docker
参考资料 https://github.com/NVIDIA/nvidia-docker/wiki/Installation#prerequisites https://github.com/NVID ...
- 怎样从外网访问内网Jboss?
本地安装了一个Jboss,只能在局域网内访问,怎样从外网也能访问到本地的Jboss呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Jboss 默认安装的Jboss端口是8080. 实现步骤 下载并 ...
- JDK 的配置和反编译工具的使用---------------Java知识点
初始Java 1995年5月,sun公司开发了一门新的编程语言------Java 詹姆斯.高斯林(Java之父),Java语言小巧安全具有可移植可跨平台性的优点. 开发java程序的步骤:编写 ,编 ...
- PID控制器开发笔记(转)
源: PID控制器开发笔记
- IDEA之HttpServletRequest之报错解决方案
@Controller public class UserController { @RequestMapping("/selectUser") public String sel ...
- MySQL更改relay-bin名称导致同步停止的解决办法
今天在优化io的时候,移动了从库relay-bin的位置,并将hostname部分去掉了,启动后,从库slave状态如下: mysql> show slave status\G; ******* ...
- nodejs 开发,手把手开始第一个服务器程序(原生)
此文章为原生 nodejs ,仅做学习使用 想学习 express 和 koa2 的小伙伴请绕路 此文章适合有HTML 和css .js 基础的小伙伴看哦 如果能帮到你,荣幸之至 文章纯手打,如有纰 ...
- 前端基础小标签3 H5新标签
第二部分H5的新标签一.<!-- mark标签 1.用于显示页面中需要重点关注的内容,就像看书需要用荧光笔划重点一样 2.浏览器通常会用黄色显示m ...
- 160CrackMe练手 001
peid判断无壳,打开输入伪码注册,根据报错od查找字符串 接下来定位到字符串周边代码 0042FA15 |. 8D55 F0 lea edx,[local.4] 0042FA18 |. 8B83 D ...
- P3311 [SDOI2014]数数
思路 看到多个子串并且不能包含的情况,想到了AC自动机 但是题目多了一个不能大于给出的n的限制条件,联想数位dp的过程,设f[i][j][0/1]表示在第i位,AC自动机的第j个节点,数位有/无限制的 ...