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

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

 #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. Java实现简单选择排序

    package select; import java.util.Scanner; /*采用最简单的选择方式:从头到尾扫描序列找出最小的记录和第一个记录交换,接着在剩下的记录中继续这种选择和交换,最终 ...

  2. 如何运用管理员身份运行cmd窗口?

    所有程序 → 附件 → 命令行提示符 → 鼠标右键“以管理员身份运行”.

  3. [Form Builer]Locking Mode and LOCK_RECORD

    Locking Mode Property Description Specifies when Oracle Forms tries to obtain database locks on rows ...

  4. Verilog-1995 VS Verilog-2001

    http://www.cnblogs.com/tshell/p/3236476.html 2001年3月IEEE正式批准了Verilog‐2001标准(IEEE1364‐2001),与Verilog‐ ...

  5. mysql自增

    主键设置自增,同时主键需要是int类型

  6. jQuery Validation Plugin学习

    http://blog.csdn.net/violet_day/article/details/14109261 jQuery Validation Plugin Demo 一.默认校验规则 (1)r ...

  7. c#面向对象编程基础

    1.  为什么要有面向对象? (1)       增加代码重用. (2)降低维护负担,将具备独特性质的代码封装起来,修改程序时,相互不会影响. 2.数据封装用来解决全局变量不易维护的问题. 3.多态: ...

  8. mvc给html扩展方法:

    mvc给html扩展方法: 注意:扩展方法和所在的类都必须是 public static如果在页面直接使用新扩展的方法,需要web.config里把Web.Helper名称命名空间加上,页面才能访问到 ...

  9. c语言对于文本的基本操作

    字符读写函数  :fgetc和fputc 字符串读写函数:fgets和fputs 数据块读写函数:freed和fwrite 格式化读写函数:fscanf和fprinf   1.字符读写: fgetc函 ...

  10. C#获取当前路径,获取当前路径的上一层路径

    C#获取当前路径的方法如下: (1)string path1 = System.Environment.CurrentDirectory; //C:\...\bin\Debug -获取和设置当前工作目 ...