HDU1115&&POJ1385Lifting the Stone(求多边形的重心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1115#
大意:给你个n,有n个点,然后给你n个点的坐标,求这n个点形成的多边形的重心的坐标。
直接套模板,我也不知道什么意思。注意在POJ上面定义double时,输出f,如果输出lf则WA,HDU上面输出lf能A。
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define inf 0x3f3f3f3f
#define eps 1e-9
typedef long long ll;
using namespace std;
int n;
struct Point
{
double x,y;
} q[];
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
Point interity(Point p[],int n)
{
Point inter= {,};
double area=;
for(int i=; i<n; i++)
{
double tmp=cross(p[i],p[(i+)%n]);
inter.x+=tmp*(p[i].x+p[(i+)%n].x);
inter.y+=tmp*(p[i].y+p[(i+)%n].y);
area+=tmp;
}
inter.x/=*area;
inter.y/=*area;
return inter;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%lf%lf",&q[i].x,&q[i].y);
}
Point temp=interity(q,n);
printf("%.2f %.2f\n",temp.x,temp.y);
}
return ;
}
HDU1115&&POJ1385Lifting the Stone(求多边形的重心)的更多相关文章
- Lifting the Stone(求多边形的重心—)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- POJ 1385 Lifting the Stone (多边形的重心)
Lifting the Stone 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/G Description There are ...
- hdu_1115_Lifting the Stone(求多边形重心)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1115 题意:给你N个点围成的一个多边形,让你求这个多边形的重心. 题解: 将多边形划分为若干个三角形. ...
- (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 ...
- Lifting the Stone(hdu1115)多边形的重心
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- poj 1115 Lifting the Stone 计算多边形的中心
Lifting the Stone Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- hdu1115 Lifting the Stone(几何,求多边形重心模板题)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...
- hdu 1115:Lifting the Stone(计算几何,求多边形重心。 过年好!)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU1115--Lifting the Stone(求凸多边形的重心)
Problem Description There are many secret openings in the floor which are covered by a big heavy sto ...
随机推荐
- ThinkPHP跳转与重定向的区别
跳转: 浏览器认为: 当前URL请求成功, 重新请求新的URL. 浏览器会 记录当前的URL 和 新的URL 在请求历史记录中. 回退, 是可以回退到, 当前的URL上的. (无论 success, ...
- (转)The windows boot configuration data file dose not contain a valid OS entry
开价蓝屏,显示: Windows failed to start. A recent hardware or software change might be the case.to fix the ...
- django admin后台css样式丢失
尼玛 坑爹啊 怎么光秃秃的,跟人家的不一样啊 打开firebug 发现报错,找不到css 通过google找到原因,是因为admin所需的js ,css等静态文件虽然都在django的安装目录内,但是 ...
- php 将一个字符串分割为组成它的字符
问: php里如何将一个字符串分割为组成它的字符? 比如hello -> [h, e, l, l, o] 以下有三种方法: 这是需要被分割的字符串: $str = 'Hello小样'; ...
- Ubuntu 16.04 LTS nodejs+pm2+nginx+git 基础安装及配置环境(未完,未整理)
-.Ubuntu 安装nodejs 以下内容均在命令行,完成,首先你要去你电脑的home目录:cd ~. [sudo] apt-get update [sudo] apt-get upgrade ap ...
- Codeforces 417 D. Cunning Gena
按monitor排序,然后状压DP... . D. Cunning Gena time limit per test 1 second memory limit per test 256 megaby ...
- Perfmon - Windows 自带系统监测工具
本文转载自oscar999 一. 简述 可以用于监视CPU使用率.内存使用率.硬盘读写速度.网络速度等. Perfmon提供了图表化的系统性能实时监视器.性能日志和警报管理,系统的性能日志可定义为二进 ...
- [转]Mac下cocos2dx-3.2+Xcode环境配置和项目创建
原文:http://blog.csdn.net/u012200908/article/details/38070885 这是有关环境配置的第二篇教程,第一篇讲的是win8下的环境配置.这里我们使用C+ ...
- 项目中整合第三方插件与SpringMVC数据格式化关于ip地址
一.Bootstrap 响应式按钮 <div calss="col-sm-2"> <button class="btn btn-default btn- ...
- centos7常用命令集合
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] CentOS7 常用命令集合 这两天一直在对CentOS 7.2进行初体验,各种学习命令肿么用,不过其实大多和DOS是一 ...