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

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

 #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. js按值传递还是按引用传递?

    js和其他大部分语言一样,有基本类型和引用类型.因此访问变量就有按值和按引用两种方式,但是传参的时候却只能按值传递.基本类型作为参数时按值传递自然无可厚非,但引用类型作为参数也按值传递就让人有点困惑了 ...

  2. 面向对象(POP)和面向过程(OOP)

    我对面向对象和面向过程的理解 面向过程:(procedure oriented programming 即:POP) 面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤一步一步实现,使用的时 ...

  3. mvn export runnable jar

    mvn dependency:copy-dependencies <build> <plugins> <plugin> <groupId>org.apa ...

  4. Flume简介与使用(一)——Flume安装与配置

    Flume简介与使用(一)——Flume安装与配置 Flume简介 Flume是一个分布式的.可靠的.实用的服务——从不同的数据源高效的采集.整合.移动海量数据. 分布式:可以多台机器同时运行采集数据 ...

  5. mysql sqlmap 注入尝试

    假设注入点为 http://www.abc.com/news.php?id=12 //探测数据库信息 sqlmap -u http://www.abc.com/news.php?id=12 –dbs ...

  6. Java并发(6)带返回结果的任务执行

    携带结果的任务 JDK5提供了有可返回值的任务的执行.java.util.concurrent中Callable与Futrue用以实现带返回值的任务执行. 使用Callable与Futrue与使用Ru ...

  7. Oracle--常见Exception

    1.  错 误 名 称 错误代码    错 误 含 义 2.  CURSOR_ALREADY_OPEN ORA_06511   试图打开已经打开的游标 3.  INVALID_CURSOR  ORA_ ...

  8. C++学习(四)

    一.拷贝构造函数和拷贝赋值运算符1.拷贝构造:用一个已有的对象,构造和它同类型的副本对象——克隆.2.形如class X {  X (const X& that) { ... }};的构造函数 ...

  9. Browser 对象

    Browser 对象 window对象表示浏览器中打开的窗口如果文档包含框架(iframe 或 iframe标签),浏览器会为HTML文档创建一个window对象,并为每个框架创建一个额外的windo ...

  10. 使用RequireJS优化Web应用前端

    require.js官网:http://requirejs.org/docs/download.html 一篇不错的文章:http://www.csdn.net/article/2012-09-27/ ...