栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3855 Blast the Enemy!

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3855 Blast the Enemy!

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<stdlib.h>#include<vector>#include<cmath>#include<queue>#include<set>using namespace std;#define N 100000#define LL long long#define INF 0xfffffffconst double eps = 1e-8;const double pi = acos(-1.0);const double inf = ~0u>>2;struct point{    double x,y;    point(double x=0,double y = 0):x(x),y(y){}}p[N];typedef point pointt;point operator -(point a,point b){    return point(a.x-b.x,a.y-b.y);}double cross(point a,point b){    return a.x*b.y-a.y*b.x;}int main(){    int i,j,n;    int kk = 0;    while(scanf("%d",&n)&&n)    {        for(i = 0 ;  i< n; i++)        scanf("%lf%lf",&p[i].x,&p[i].y);        p[n] = p[0];        double sx = 0,sy = 0,sum =0 ;        for(i = 1; i < n-1 ;i++)        { double ts = cross(p[i]-p[0],p[i+1]-p[0])/2; double x = p[0].x+p[i].x+p[i+1].x; double y = p[0].y+p[i].y+p[i+1].y; sum+=ts; sx+=x*ts; sy+=y*ts;        }        printf("Stage #%d: %.6f %.6fn",++kk,sx/3.0/sum,sy/3.0/sum);    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/367768.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号