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进行叉乘,所得的一般即为答案。

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<algorithm>
  4. using namespace std;
  5. const int MAXN=300+10;
  6.  
  7. struct Point
  8. {
  9. double x, y;
  10. Point(double x=0, double y=0):x(x),y(y) { }
  11.  
  12. };
  13. typedef Point Vector;
  14. Vector operator + (const Vector& A, const Vector& B) { return Vector(A.x+B.x, A.y+B.y); }
  15. Vector operator - (const Point& A, const Point& B) { return Vector(A.x-B.x, A.y-B.y); }
  16. Vector operator * (const Vector& A, double p) { return Vector(A.x*p, A.y*p); }
  17. Vector operator / (const Vector& A, double p) { return Vector(A.x/p, A.y/p); }
  18.  
  19. double Cross(const Vector& A, const Vector& B) { return A.x*B.y - A.y*B.x; }
  20.  
  21. //两直线交点,参数式。
  22. Point GetLineIntersection(const Point& P, const Vector& v, const Point& Q, const Vector& w) {
  23. Vector u = P-Q;
  24. double t = Cross(w, u) / Cross(v, w);
  25. return P+v*t;
  26. }
  27.  
  28. Point a,b,c;
  29. int main()
  30. {
  31. int T;
  32. scanf("%d",&T);
  33. while(T--)
  34. {
  35. scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
  36. Vector BD=(c-b)/3;
  37. Vector AF=(b-a)/3;
  38. Vector CE=(a-c)/3;
  39. Point d=b+BD;
  40. Point f=a+AF;
  41. Point e=c+CE;
  42. Point p=GetLineIntersection(d,a-d,b,b-e);
  43. Point q=GetLineIntersection(c,c-f,b,b-e);
  44. Point r=GetLineIntersection(c,c-f,d,a-d);
  45. printf("%.0lf\n",Cross(p-q,p-r)/2);
  46. }
  47. return 0;
  48. }

UVA 11437 - Triangle Fun 向量几何的更多相关文章

  1. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  2. 简单几何(求交点) UVA 11437 Triangle Fun

    题目传送门 题意:三角形三等分点连线组成的三角形面积 分析:入门题,先求三等分点,再求交点,最后求面积.还可以用梅涅劳斯定理来做 /********************************** ...

  3. uva 11437 - Triangle Fun

    计算几何: 直线交点: #include<cstdio> using namespace std; struct node { double x,y; node(,):x(x),y(y){ ...

  4. uva 11401 Triangle Counting

    // uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...

  5. UVa 11437 (梅涅劳斯定理) Triangle Fun

    题意: 给出三角形ABC顶点的坐标,DEF分别是三边的三等分点.求交点所形成的三角形PQR的面积. 分析: 根据梅涅劳斯定理,我们得到: ,解得 另外还有:,解得 所以AR : RP : PD = 3 ...

  6. UVA 11178 Morley's Theorem(几何)

    Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...

  7. UVA 11796 - Dog Distance 向量的应用

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  8. UVA 11646 - Athletics Track || UVA 11817 - Tunnelling the Earth 几何

    题目大意: 两题几何水题. 1.UVA 11646 - Athletics Track 如图,体育场的跑道一圈400米,其中弯道是两段半径相同的圆弧,已知矩形的长宽比例为a:b,求长和宽的具体数值. ...

  9. UVa 488 - Triangle Wave

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

随机推荐

  1. 洛谷 P1994 有机物燃烧

    P1994 有机物燃烧 题目背景 本来准备弄难点的,还是算了吧 题目描述 输入一种有机物,输出与氧气反应化学方程式中CO2和H2O的系数 输入输出格式 输入格式: 一行,一个字符串,表示有机物 输出格 ...

  2. 集群通信组件tribes之用法

    上面已经对tribes的内部实现机制及原理进行了深入的剖析.在理解它的设计原理后看看怎样使用tribes.整个使用相当简单便捷,仅仅须要四步: ① 定义一个消息对象,因为这个消息对象是要在网络之间传递 ...

  3. WebGoat学习(一)--环境搭建

    参考https://www.owasp.org/index.php/Category:OWASP_WebGoat_Project https://github.com/WebGoat/WebGoat ...

  4. C#定义变量

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. js防止提交数据之后的按钮连击

    js防止提交数据之后的按钮连击 一.实例描述 当页面提交的数据特别多时,页面会反应比较迟钝,此时如果用户等不及而连续单击按钮,导致数据重复提交.本案例就是为了防止数据重复提交. 二.截图 三.代码 & ...

  6. MyBatis映射

    mybatis-config.xml映射文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...

  7. golang binarySearch

    func binarySearch(nodes []*node, word Text) (int, bool) { start := end := len(nodes) - // 特例: { // 当 ...

  8. golang语言入门及安装

    golang语言入门及安装 go语言是google在2009年发布的开源编程语言使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全.支持并行进程. 本次讲解在windows上安装go语言的开 ...

  9. 解决root登录 -bash-4.2# 的问题

  10. pip 更新安装失败解决方法

    python3 -m ensurepip https://stackoverflow.com/questions/28664082/python-no-module-pip-main-error-wh ...