题目链接: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(求多边形的重心)的更多相关文章

  1. Lifting the Stone(求多边形的重心—)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...

  2. POJ 1385 Lifting the Stone (多边形的重心)

    Lifting the Stone 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/G Description There are ...

  3. hdu_1115_Lifting the Stone(求多边形重心)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1115 题意:给你N个点围成的一个多边形,让你求这个多边形的重心. 题解: 将多边形划分为若干个三角形. ...

  4. (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 ...

  5. Lifting the Stone(hdu1115)多边形的重心

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...

  6. poj 1115 Lifting the Stone 计算多边形的中心

    Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. hdu1115 Lifting the Stone(几何,求多边形重心模板题)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...

  8. hdu 1115:Lifting the Stone(计算几何,求多边形重心。 过年好!)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. HDU1115--Lifting the Stone(求凸多边形的重心)

    Problem Description There are many secret openings in the floor which are covered by a big heavy sto ...

随机推荐

  1. 得到application

    ServletContext application = request.getSession().getServletContext();        String basePath = (Str ...

  2. loadOnStartup = 1

    在servlet的配置当中,<load-on-startup>5</load-on-startup>的含义是:标记容器是否在启动的时候就加载这个servlet.当值为0或者大于 ...

  3. 考虑下面两个JSP文件代码片断: test1.jsp:

    <HTML> <BODY> <% pageContext.setAttribute(”ten”,new Integer(10));%> //1 </BODY& ...

  4. ThinkPHP项目笔记之控制器常用语法

    如,有数据表:tmp,以下以此为例. $a = M('Tmp'); $a -> select(); $a -> where(condition)->select(); $a -> ...

  5. LoadRunner Error code 10053,Software caused connection abort

    发现问题的应用场景  C/S结构程序,请求响应采用异步机制.即客户端发送一个请求后不是一直等待这个结果,客户端将请求存放在请求队列并获得一个JOBID,服务器运行后将运行结果存放在响应队列,客户端定时 ...

  6. 【LDA】nlp

    http://pythonhosted.org/lda/getting_started.html http://radimrehurek.com/gensim/

  7. 3D分子构型该怎么优化

    很多的化学领域的专业人士都知道,分子的性质往往是有分子的结构所决定的,但是在实验室研究的过程中很难观察到稳定分子的结构,这往往是因为中间体寿命过短或者是混合物难以分离造成的,这个时候就需要通过计算化学 ...

  8. xdebug常用配置

    ;指定xdebug文件 zend_extension = "F:\tools\develop_tools\php\php_xdebug-2.2.2-5.4-vc9.dll" ;xd ...

  9. VC++分页打印实现

    VC++分页打印实现:  C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243 ...

  10. Linux内核态、用户态简介与IntelCPU特权级别--Ring0-3

    一.现代操作系统的权限分离: 现代操作系统一般都至少分为内核态和用户态.一般应用程序通常运行于用户态,而当应用程序调用系统调用时候会执行内核代码,此时会处于内核态.一般的,应用程序是不能随便进入内核态 ...