Triangle Fun UVA - 11437(一个数学定理 + 三角形求面积)

Triangle Fun UVA - 11437

题意:

给你一个三角形,被三条三等分线划分。要你求中间三角形的面积。
在这里插入图片描述

思路:(ans = S Δ a b c 7 \frac{S\Delta abc}{7} 7SΔabc

简明版:
由梅涅劳斯定理得:如果一条直线与△ABC的三边AB、BC、CA或其延长线交于F、D、E点,那么(AF/FB)(BD/DC)(CE/EA)=1
那么对于该问题,在△ABE中,由该定理得:(AF/FB)(BQ/QE)(EC/CA)=1,因为(AF/FB)=1/2,(EC/CA) =1/3
所以,(BQ/QE) = 1/6,则S△BQC/S△QEC=1/6,则S△BEC/S△QEC = 1/7,又因为S△BEC = 1/3S,所以S△QQR=S△ABC-(S△BEC3-S△QEC3),即S△QQR = S△ABC/7
证明
先证明一个引理:(梅涅劳斯定理)
如果一条直线与△ABC的三边AB、BC、CA或其延长线交于F、D、E点,那么(AF/FB)(BD/DC)(CE/EA)=1.
证明:
过点A作AG‖BC交DF的延长线于G,
则AF/FB=AG/BD ,BD/DC=BD/DC ,CE/EA=DC/AG.
三式相乘得:(AF/FB)(BD/DC)(CE/EA)=(AG/BD)(BD/DC)(DC/AG)=1
由以上引理,有:
(AF/FB)(BC/CD)(DL/AL)=1
化简上式,可以得到:DL/AL=4/3 ①
又(AE/EC)(CB/BD)(DM/AM)=1
化简上式,可以得到:DM/AM=1/6 ②
由①,②联立,可以得到:LM=3DM,又DM/AM=1/6
所以AL=LM.同理可得:CN=NL.
所以S△LMN=S△LMC/2 ③
S△LMC=3S△LDC/4 ④
而LD/AD=3+1/(3+3+1)=4/7
所以S△LDC=4S△ADC/7 ⑤
又S△ADC=2S△ABC/3 ⑥
由③④⑤⑥可得:
S△LMN=△ABC/7

有了如上定理,那么就是求三角形面积了

  1. 用叉积求面积
  2. 或者用余弦定理求角度,再求面积。

AC

#include <iostream>
#include <bits/stdc++.h>
#define For(i,x,y) for(int i=(x); i<=(y); i++)
#define fori(i,x,y) for(int i=(x); i<(y); i++)
#define rep(i,y,x) for(int i=(y); i>=(x); i--)
#define mst(x,a) memset(x,a,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
typedef pair<ll,ll>pai;
//
struct Point {
    double x, y;
    Point(double x = 0, double y = 0):x(x),y(y){}
};
typedef Point Vector;
Vector operator + (Vector A, Vector B) { return Vector(A.x + B.x, A.y + B.y); }
Vector operator - (Vector A, Vector B) { return Vector(A.x - B.x, A.y - B.y); }
Vector operator * (Vector A, double p) { return Vector(A.x*p, A.y*p); }
Vector operator / (Vector A, double p) { return Vector(A.x/p, A.y/p); }
//
bool operator < (const Point& a, const Point& b){
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}
const double eps = 1e-10;
int dcmp(double x){
    if(fabs(x) < eps)return 0;
    else return x < 0 ? -1 : 1;
}
bool operator == (const Point&a, const Point& b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}
//
double Dot(Vector A, Vector B) { return A.x*B.x + A.y*B.y; }
double Length(Vector A) { return sqrt(Dot(A, A)); }
double Angle(Vector A, Vector B) { return acos(Dot(A, B) / Length(A) / Length(B)); }
//
double Cross(Vector A, Vector B) { return A.x*B.y - A.y*B.x; }
double Area2(Point A, Point B, Point C) { return Cross(B-A, C-A); }
double getdis(Point A, Point B) { return sqrt((A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y)); }
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tt; cin>>tt;
    while(tt--){
        Point p[3];
        fori(i,0,3)cin>>p[i].x>>p[i].y;
        //solution 1
        double area = Area2(p[0], p[1], p[2])/2;
        /* solution2
        double d[3] = {getdis(p[0], p[1]), getdis(p[0], p[2]), getdis(p[1], p[2])};
        double angle = acos((d[0]*d[0] + d[1]*d[1] - d[2]*d[2]) / 2 / d[0] / d[1]);
        double area = sin(angle)*d[0]*d[1]/2;
        */
        int area_int = fabs(area)/7 + 0.5;
        cout<<area_int<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值