计算几何的题目,很简单;

自己随手敲了个,纪念下!

 #include<cstdio>
#include<cmath>
using namespace std; struct point
{
double x,y;
point(double x=,double y=):x(x),y(y) { }
} a,b,c,d; point midd(point a,point b)
{
return point((a.x+b.x)/2.0,(a.y+b.y)/2.0);
}
point operator + (point a,point b)
{
return point(a.x+b.x,a.y+b.y);
}
point operator - (point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
point operator * (point a,double p)
{
return point(a.x*p,a.y*p);
}
point operator / (point b,double p)
{
return point(a.x/p,a.y/p);
}
double cross(point a,point b)
{
return a.x*b.y-b.x*a.y;
}
point getlineintersection(point p,point v,point q,point w)
{
point u=p-q;
double t=cross(w,u)/cross(v,w);
return p+v*t;
}
double area(point a,point b,point c)
{
return cross(b-a,c-a)/2.0;
}
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double line(point a,point b,point c,point d)
{
return dis(a,b)+dis(b,c)+dis(c,d)+dis(d,a);
} int main()
{
int t,ca;
scanf("%d",&t);
while(t--)
{
scanf("%d",&ca);
printf("%d ",ca);
a.x=0.0,a.y=0.0,b.y=0.0;
scanf("%lf%lf%lf%lf%lf",&b.x,&c.x,&c.y,&d.x,&d.y);
point dd=midd(a,b);
point aa=midd(b,c);
point cc=midd(a,d);
point bb=midd(c,d);
point aaa=getlineintersection(d,d-dd,a,a-aa);
point bbb=getlineintersection(a,aa-a,b,bb-b);
point ccc=getlineintersection(c,cc-c,b,bb-b);
point ddd=getlineintersection(c,cc-c,d,dd-d);
printf("%.3lf ",area(a,b,bbb)/160.0);
printf("%.3lf ",area(b,c,ccc)/160.0);
printf("%.3lf ",area(c,d,ddd)/160.0);
printf("%.3lf ",area(d,a,aaa)/160.0);
printf("%.3lf ",((area(ddd,aaa,bbb)+area(bbb,ccc,ddd))/160.0));
printf("%.0lf\n",ceil(line(aaa,bbb,ccc,ddd)*16.5));
}
return ;
}

【2011 Greater New York Regional 】Problem G: Rancher's Gift的更多相关文章

  1. 【2011 Greater New York Regional 】Problem I :The Golden Ceiling

    一道比较简单但是繁琐的三维计算几何,找错误找的我好心酸,没想到就把一个变量给写错了 = =: 题目的意思是求平面切长方体的截面面积+正方体顶部所遮盖的面积: 找出所有的切点,然后二维凸包一下直接算面积 ...

  2. 【2011 Greater New York Regional 】Problem H: Maximum in the Cycle of 1

    也是一个数学题: 主要用到的是排列组合的知识,推推公式就行了,挺简单的: 唯一要注意的是A(0,0)=1: 在这个上面WA了几次,= = 代码: #include<stdio.h> #de ...

  3. 【2011 Greater New York Regional 】Problem B The Rascal Triangle

    一个简单的规律题,每一列都是一个等差数列: 代码: #include<cstdio> #define ll long long using namespace std; int main( ...

  4. 【贪心+中位数】【新生赛3 1007题】 Problem G (K)

    Problem G Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  5. Poj(2407),Greater New York Regional 2015 (D)

    题目链接:http://poj.org/problem?id=2407 Relatives Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  6. 【2011集训贾志鹏】Crash 的数字表格

    题面 题目分析 (默认\(n<m\)) 题目要求\(\sum\limits_{i=1}^n\sum\limits_{j=1}^mlcm(i,j)\). 由\(lcm(i,j)=\frac{i\c ...

  7. [NOIp 1998 提高组]Probelm 2 连接多位数【2011百度实习生笔试题】

    /*====================================================================== [NOIp 1998 提高组]Probelm 2 连接 ...

  8. 回文自动机 + DFS --- The 2014 ACM-ICPC Asia Xi’an Regional Contest Problem G.The Problem to Slow Down You

    The Problem to Slow Down You Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.actio ...

  9. Gym 101981G - Pyramid - [打表找规律][2018-2019 ACM-ICPC Asia Nanjing Regional Contest Problem G]

    题目链接:http://codeforces.com/gym/101981/attachments The use of the triangle in the New Age practices s ...

随机推荐

  1. position定位问题

    position属性规定了元素的定位类型,默认为static.该属性还可以有下值:absolute:生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位.fixed:生成绝对定位的 ...

  2. android 开发过程中碰到的 Failed to create the part's controls 问题

    在开发android的过程中,遇到一个很奇怪的问题,出现了“ Failed to create the part's controls” 的错误,查询了N多资料,然后逐条删除代码测试, 后来发现是变量 ...

  3. HDFS的java客户端操作代码(Windows上面打jar包,提交至linux运行)

    1.通过java.net.URL实现屏幕显示demo1文件的内容 package Hdfs; import java.io.InputStream; import java.net.URL; impo ...

  4. mongodb环境部署

    mongodb 环境部署 1.环境说明 安装软件:mongodb-linux-x86_64-.tgz 软件安装位置:/usr/local/mongodb 数据存放位置:/var/mongodb/dat ...

  5. §12 循环101-while循环

    §12   循环101-while循环 While和for具有一定的可替换性.语法如下: while test body continue终止当次循环,break退出整个循环. 注意while之后要用 ...

  6. window nodejs 版本切换 nvmw

    参考文档:https://cnodejs.org/topic/5338c5db7cbade005b023c98 nvmw 下载到本地 git clone https://github.com/hako ...

  7. java中对除法取2位小数的一点试验

    如下程序, double a = 12.3333333,b = 11.22222222222; double c = 0; String d = String.format("%.2f&qu ...

  8. js读取Excel文件数据-IE浏览器

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...

  9. Deep Learning 学习随记(三)Softmax regression

    讲义中的第四章,讲的是Softmax 回归.softmax回归是logistic回归的泛化版,先来回顾下logistic回归. logistic回归: 训练集为{(x(1),y(1)),...,(x( ...

  10. APP评价(星星点赞)很简单

    1.用代码或者storyboard创建5个button(现在一般都是5个星星) 我用的是storyboard 记得一定要设置button的tag值 在.h中 @property (weak, nona ...