zoukankan      html  css  js  c++  java
  • UVA

     

    题目大意:任意△ABC中F、D、E分别为三边的三等分点中点,将其分别与对应的顶点相连,得到一个新的△RPQ。

                    现在给出△ABC的坐标,求△RPQ的面积

    解题思路:求出△ABC的面积三角形 ABC 的面积

                      可以证明:S△BPQ :S△ABC = 1 : 7

     

    也可以用每个边用向量缩减三倍求三分点,然后求三条直线的交点,然后就可以求面积了。

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <cmath>
     5 #include <algorithm>
     6 #include <string>
     7 #include <queue>
     8 #include <vector>
     9 #include <set>
    10 #include <map>
    11 #define ll long long
    12 #define INF 0x3f3f3f3f
    13 #define lowvit(x) x&(-x)
    14 #define N 110
    15 #define M 110
    16 using namespace std;
    17 struct Point {
    18     double x, y;
    19 };
    20 double dist(Point *A, Point *B) {
    21     return sqrt((A->x - B->x)*(A->x - B->x) + (A->y - B->y)*(A->y - B->y));
    22 }
    23 double area(Point *A, Point *B, Point *C) {
    24     double a = dist(A, B);
    25     double b = dist(A, C);
    26     double c = dist(C, B);
    27     double s = (a+b+c)/2.0;
    28     return sqrt(s*(s-a)*(s-b)*(s-c));
    29 }
    30 int main() {
    31     int t;
    32     Point A, B, C, D, E, F, Q, R, P;
    33     cin >> t;
    34     while(t--) {
    35         cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y;
    36         double are = area(&A, &B, &C);
    37         if(are < 0) are = -are;
    38         printf("%.0f
    ",are/7);
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    经典机器学习算法总结
    从0开始学Python---01
    Android-Canvas.save() Canvas.restore() 总结
    Android-属性动画原理总结
    设计模式-外观模式
    设计模式-模板方法
    设计模式-装饰者模式
    设计模式-策略模式
    设计模式-工厂方法模式
    设计模式-简单工厂模式
  • 原文地址:https://www.cnblogs.com/xingkongyihao/p/7281202.html
Copyright © 2011-2022 走看看