UVA 11437 - Triangle Fun 向量几何
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2432
题目大意:
如图,定义三角形ABC,在BC,CA,AB上分别取边D,E,F,使得CD=2BD,AE=2CE,BF=2AF,求三角形PQR的面积。
思路:
先求出D,E,F三点坐标,然后求出PQR三点坐标,最后对pr,pq进行叉乘,所得的一般即为答案。
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- using namespace std;
- const int MAXN=300+10;
- struct Point
- {
- double x, y;
- Point(double x=0, double y=0):x(x),y(y) { }
- };
- typedef Point Vector;
- Vector operator + (const Vector& A, const Vector& B) { return Vector(A.x+B.x, A.y+B.y); }
- Vector operator - (const Point& A, const Point& B) { return Vector(A.x-B.x, A.y-B.y); }
- Vector operator * (const Vector& A, double p) { return Vector(A.x*p, A.y*p); }
- Vector operator / (const Vector& A, double p) { return Vector(A.x/p, A.y/p); }
- double Cross(const Vector& A, const Vector& B) { return A.x*B.y - A.y*B.x; }
- //两直线交点,参数式。
- Point GetLineIntersection(const Point& P, const Vector& v, const Point& Q, const Vector& w) {
- Vector u = P-Q;
- double t = Cross(w, u) / Cross(v, w);
- return P+v*t;
- }
- Point a,b,c;
- int main()
- {
- int T;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
- Vector BD=(c-b)/3;
- Vector AF=(b-a)/3;
- Vector CE=(a-c)/3;
- Point d=b+BD;
- Point f=a+AF;
- Point e=c+CE;
- Point p=GetLineIntersection(d,a-d,b,b-e);
- Point q=GetLineIntersection(c,c-f,b,b-e);
- Point r=GetLineIntersection(c,c-f,d,a-d);
- printf("%.0lf\n",Cross(p-q,p-r)/2);
- }
- return 0;
- }
UVA 11437 - Triangle Fun 向量几何的更多相关文章
- UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)
Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...
- 简单几何(求交点) UVA 11437 Triangle Fun
题目传送门 题意:三角形三等分点连线组成的三角形面积 分析:入门题,先求三等分点,再求交点,最后求面积.还可以用梅涅劳斯定理来做 /********************************** ...
- uva 11437 - Triangle Fun
计算几何: 直线交点: #include<cstdio> using namespace std; struct node { double x,y; node(,):x(x),y(y){ ...
- uva 11401 Triangle Counting
// uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...
- UVa 11437 (梅涅劳斯定理) Triangle Fun
题意: 给出三角形ABC顶点的坐标,DEF分别是三边的三等分点.求交点所形成的三角形PQR的面积. 分析: 根据梅涅劳斯定理,我们得到: ,解得 另外还有:,解得 所以AR : RP : PD = 3 ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- UVA 11796 - Dog Distance 向量的应用
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11646 - Athletics Track || UVA 11817 - Tunnelling the Earth 几何
题目大意: 两题几何水题. 1.UVA 11646 - Athletics Track 如图,体育场的跑道一圈400米,其中弯道是两段半径相同的圆弧,已知矩形的长宽比例为a:b,求长和宽的具体数值. ...
- UVa 488 - Triangle Wave
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
随机推荐
- 洛谷 P1994 有机物燃烧
P1994 有机物燃烧 题目背景 本来准备弄难点的,还是算了吧 题目描述 输入一种有机物,输出与氧气反应化学方程式中CO2和H2O的系数 输入输出格式 输入格式: 一行,一个字符串,表示有机物 输出格 ...
- 集群通信组件tribes之用法
上面已经对tribes的内部实现机制及原理进行了深入的剖析.在理解它的设计原理后看看怎样使用tribes.整个使用相当简单便捷,仅仅须要四步: ① 定义一个消息对象,因为这个消息对象是要在网络之间传递 ...
- WebGoat学习(一)--环境搭建
参考https://www.owasp.org/index.php/Category:OWASP_WebGoat_Project https://github.com/WebGoat/WebGoat ...
- C#定义变量
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- js防止提交数据之后的按钮连击
js防止提交数据之后的按钮连击 一.实例描述 当页面提交的数据特别多时,页面会反应比较迟钝,此时如果用户等不及而连续单击按钮,导致数据重复提交.本案例就是为了防止数据重复提交. 二.截图 三.代码 & ...
- MyBatis映射
mybatis-config.xml映射文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...
- golang binarySearch
func binarySearch(nodes []*node, word Text) (int, bool) { start := end := len(nodes) - // 特例: { // 当 ...
- golang语言入门及安装
golang语言入门及安装 go语言是google在2009年发布的开源编程语言使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全.支持并行进程. 本次讲解在windows上安装go语言的开 ...
- 解决root登录 -bash-4.2# 的问题
- pip 更新安装失败解决方法
python3 -m ensurepip https://stackoverflow.com/questions/28664082/python-no-module-pip-main-error-wh ...