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

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

 #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 float、double精度研究(转)

    在java中运行一下代码System.out.println(2.00-1.10);输出的结果是:0.8999999999999999很奇怪,并不是我们想要的值0.9 再运行如下代码:System.o ...

  2. Android(java)学习笔记148:Eclipse中代码提示去掉@override,不然就报错!

    把项目下载下来后有@Override的注释的方法会报错,如果把@Override去掉就不报错了.经过查阅后发现:@override注释在jdk1.5环境下只能用于对继承的父类的方法的重写,但不能用于对 ...

  3. the second assignment of software testing

    作业2期心得体会.第一期仍有未完成的项目,比如应该指定所读课题的范围,是关于哪个方面的. 作业项目一: 安装并使用CheckStyle/PMD与FindBug 现在网络上查找了一番发现checkSty ...

  4. js 字符串编码转换函数

    escape 方法 对 String 对象编码以便它们能在所有计算机上可读, escape(charString) 必选项 charstring 参数是要编码的任意 String 对象或文字. 说明 ...

  5. jQuery 基础

    慕课网 2016-01-07 每一次操作select的时候,总是要出来翻一下资料,不如自己总结一下,以后就翻这里了. 比如<select class="selector"&g ...

  6. Git之路--1

    昨天下午到今天早上,终于搞定了github.过程很难过,不过看到自己的github上有代码了.还是小小的开心了一下.暂时没时间分享相关技术,附带微博链接,有想试试上传上Github的小伙伴可以查看我的 ...

  7. C# Callback 回调实用讲解 [原创]

    这个是2011年写的一个技术贴,现在看可能有点过时了,有兴趣的朋友也可以看一下. 一. 描述 在开发winform程序时不会考虑页面刷新问题,只要控制好线程别导致假死就ok了,但是在开发web页面程序 ...

  8. android中实现“再按一次退出”功能

    首先,定义两次点击退出按钮的时间间隔:private static final long INTERNAL_TIME=2000; 然后,定义一个当前时间的变量:private long exitTim ...

  9. Codevs 2843 拯救炜哥

    2843 拯救炜哥 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 有一天,炜哥和欧能干一起去大魔王家里做(dao)客(luan), ...

  10. Codevs 1702 素数判定 2(Fermat定理)

    1702 素数判定 2 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 传送门 题目描述 Description 一个数,他是素数么? 设他为P满足(P< ...