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 ...
随机推荐
- 第一周java测验感想
在正式开学的第一周,建民老师就给我们来了一个下马威.我本身的编程基础比较差,不知道怎么去想,怎么去一步步的去完成这么一个工程.所以我在星期四的下午十分的痛苦…因为不知道怎么搞嘛.尽管在暑假的时候看了 ...
- 动手动脑-Java的方法重载
例: Using overloaded methods public class MethodOverload { public static void main(String[] args) { ...
- Redis慢查询日志学习功能
慢查询日志 什么是SLOW LOG? Slow log是Redis用来记录查询执行时间超过给定时长的命令请求的日志系统.查询执行时间指的是不包括像客户端响应(talking).发送回复等IO操作,而单 ...
- Django框架----模板语法
Django模板系统 官方文档 一.什么是模板? 只要是在html里面有模板语法就不是html文件了,这样的文件就叫做模板. 二.模板语法分类 只需要记两种特殊符号: {{ }}和 {% %} 变量 ...
- sql server 触发器的简单用法
触发器 -- 一下写的都是我对触发器的理解 当在执行insert . delete . 等操作的时候 随便要做一些额外的操作, 比如在添加的时候就会将新添加的数据存到inserted表中 写个实例 ...
- 第三节 深入JavaScript
函数的返回值:(把函数体内的数据传出到函数体外) 什么是函数的返回值:函数执行结果.可以没有返回值 一种函数应该只返回一种类型的值 函数传参:(与函数返回值相反,把外面数据传入函数体内) 可变参(不定 ...
- centos7开放及查看端口
centos7中的防火墙改成了firewall,使用iptables无作用,开放端口的方法如下: firewall-cmd --zone=public --add-port=80/tcp --perm ...
- ORA-00600: internal error code, arguments: [13030], [20]一例解决
两年没有接触oracle了,中午,一环境update from的时候出现ORA-00600: internal error code, arguments: [13030], [20]异常,经查,官网 ...
- Redis热点Key发现及常见解决方案!
一.热点Key问题产生的原因 1.用户消费的数据远大于生产的数据(热卖商品.热点新闻.热点评论.明星直播). 在日常工作生活中一些突发的的事件,例如:双十一期间某些热门商品的降价促销,当这其中的某一件 ...
- 阶段性总结(2017 June 10 - 2017 July 10)
综述 我在全面剖析了自身的特质以后,针对于工程技术领域的经验丰富优势.科学研究领域的理论薄弱劣势.我制定了全面夯实科学研究理论基础的学习计划.全面提高效率抓大放小的精力分配原则. 执行成果 线性代数( ...