关于p6160向量

· · 题解

P6160题解

题目传送门

平面向量知识储备

  1. \overrightarrow{a}\cdot\overrightarrow{b}= |\overrightarrow{a}|\cdot|\overrightarrow{b}| \cdot\cos<\overrightarrow{a},\overrightarrow{b}>
  2. 三角形法则
  3. 平行四边形法则
  4. |\overrightarrow{a}|+|\overrightarrow{b}|\ge |\overrightarrow{a}\pm \overrightarrow{b}|\ge ||\overrightarrow{a}|-|\overrightarrow{b}||

思路梳理

1.转形式:根据完全平方和公式,将σ转换形式,便于最小值求解

2.分类讨论:(1) r_1+r_2>r_3 (2) r_1+r_2\le r_3

具体分析及代码

σ= min(\overrightarrow{a}\cdot\overrightarrow{b}+\overrightarrow{b}\cdot\overrightarrow{c}+\overrightarrow{a}\cdot\overrightarrow{c}) =min[\dfrac{(\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c})^2-\overrightarrow{a}^2-\overrightarrow{b}^2-\overrightarrow{c}^2}{2}] =min[\dfrac{(\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c})^2-r_1^2-r_2^2-r_3^2}{2}]

其中,-r_1^2-r_2^2-r_3^2为定值,所以当(\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c})^2取最小时σ有最小值

分类讨论:

1.r_1+r_2>r_3时,即\overrightarrow{a},\overrightarrow{b},\overrightarrow{c}可以构成三角形,有\overrightarrow{a}+\overrightarrow{b}=\overrightarrow{c},有|\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c}|\ge |\overrightarrow{a}+\overrightarrow{b}|-|\overrightarrow{c}|=0.所以σ=-\dfrac{r_1^2+r_2^2+r_3^2}{2}

代码:

if(r1+r2>r3)
{
    cout<<fixed<<setprecision(1)<<-((pow(r1,2)+pow(r2,2)+pow(r3,2)))/2;
}

2.r_1+r_2\le r_3时,即\overrightarrow{a},\overrightarrow{b},\overrightarrow{c}不可以构成三角形,有|\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c}|\ge |\overrightarrow{c}|-|\overrightarrow{a}+\overrightarrow{b}|,\overrightarrow{a}+\overrightarrow{b}=x\overrightarrow{c},0<x<1,所以|\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c}| \ge (1-x)|\overrightarrow{c}|又有|\overrightarrow{a}+\overrightarrow{b}|=|x\overrightarrow{c}|\le |\overrightarrow{a}|+|\overrightarrow{b}| (由于有平方所以只计算模即可),当|x\overrightarrow{c}|取最大时|\overrightarrow{a}+\overrightarrow{b}+\overrightarrow{c}|取最小值-(r_1+r_2)+r_3=r_3-r_1-r_2

σ= \dfrac{(r_3-r_1-r_2)^2-r_1^2-r_2^2-r_3^2}{2}=\dfrac{2(r_1r_2-r_2r_3-r_1r_3)}{2}=r_1r_2-r_2r_3-r_1r_3(共线)

代码:

else
{
   cout<<fixed<<setprecision(1)<<r1*r2-r2*r3-r1*r3;
}

AC代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
    long double r1,r2,r3;
    cin>>r1>>r2>>r3;
    if(r1+r2-r3>=0 )
    {
        cout<<fixed<<setprecision(1)<<-((pow(r1,2)+pow(r2,2)+pow(r3,2)))/2;//r1,r2,r3
    }
    else
    {
        cout<<fixed<<setprecision(1)<<r1*r2-r2*r3-r1*r3;
    }
    return 0;
 } 

注意!

本题定义需使用 long double