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 ...
随机推荐
- Linux账号管理
Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统. 用户的账号一方面可以帮助系统管理员对使用系统的用户进行 ...
- (2018干货系列十)最新android开发学习路线整合
怎么学Android Android是一个以Linux为基础的半开源操作系统,主要用于移动设备,由Google和开放手持设备联盟开发与领导.据2011年初数据显示仅正式上市两年的操作系统Android ...
- 怎样从外网访问内网WampServer?
本地安装了一个WampServer,只能在局域网内访问,怎样从外网也能访问到本地的WampServer呢?本文将介绍具体的实现步骤. 准备工作 安装并启动WampServer 默认安装的WampSer ...
- jq如何获取服务器的时间
$.ajax({type:"OPTIONS",url:"/",complete:function(x){alert(x.getResponseHeader(&q ...
- MyEclipse非正常关闭问题
问题:电脑突然断电,myeclipse非正常关闭,“Package Explorer”非正常显示,出现错误“Could not create the view: An unexpected excep ...
- Myeclipse错误:Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project 'MyCastBoxAPP' java.lang.NullPointerException
报错起因: 当需要替某项目更名(即右键选定项目后选择Refactor->Rename),点击OK后,发生了中断,提示Undo抑或Abort,无论选择哪个,之后都将弹出以下错误提示框 错误描述: ...
- Kattis之旅——Fractional Lotion
Freddy practices various kinds of alternative medicine, such as homeopathy. This practice is based o ...
- log4j2笔记 #02# 启用异步日志
索引 参考 Making All Loggers Asynchronous 第一步,添加相应的disruptor库 第二步,设置系统属性log4j2.contextSelector 第三步,检验! 参 ...
- Golang两种方法实现MD5加密
package main import ( "crypto/md5" "fmt" "io" ) func main() { str := & ...
- mysql启动、关闭与登录
按照上述三篇随笔中的方法安装mysql,其启动.关闭和登录方法如下. mysql启动基本原理:/etc/init.d/mysqld是一个shell启动脚本,启动后最终会调用mysql\bin\mysq ...