跳到正文

题解

题解 P6160 【[Cnoi2020]向量】

WYXkk约 4 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 4 分钟
题目
P6160

版本

  1. v1当前

这种屑 MO 题有什么出出来的必要吗……

出题人的分析方法比较神仙……我就只会暴力推三角函数了。

先复述一遍题目:∣OA∣=r1,∣OB∣=r2,∣OC∣=r3|OA|=r_1,|OB|=r_2,|OC|=r_3,求σ=OA→⋅OB→+OB→⋅OC→+OC→⋅OA→\sigma=\overrightarrow{OA}\cdot\overrightarrow{OB}+\overrightarrow{OB}\cdot\overrightarrow{OC}+\overrightarrow{OC}\cdot\overrightarrow{OA} 的最小值。

假设 ∠AOB=α,∠BOC=β\angle AOB=\alpha,\angle BOC=\beta,则

σ=r1r2cos⁡α+r2r3cos⁡β+r3r1cos⁡(α−β)=r1r2cos⁡α+r2r3cos⁡β+r3r1(cos⁡αcos⁡β+sin⁡αsin⁡β)=(r1r2+r3r1cos⁡β)cos⁡α+(r3r1cos⁡β)sin⁡α+r2r3cos⁡β≥−(r1r2+r3r1cos⁡β)2+(r3r1cos⁡β)2+r2r3cos⁡β=r2r3cos⁡β−r12r22+r12r32+2r12r2r3cos⁡β\begin{aligned}\sigma&=r_1r_2\cos\alpha+r_2r_3\cos\beta+r_3r_1\cos(\alpha-\beta)\\&=r_1r_2\cos\alpha+r_2r_3\cos\beta+r_3r_1(\cos\alpha\cos\beta+\sin\alpha\sin\beta)\\&=(r_1r_2+r_3r_1\cos\beta)\cos\alpha+(r_3r_1\cos\beta)\sin\alpha+r_2r_3\cos\beta\\&\ge-\sqrt{(r_1r_2+r_3r_1\cos\beta)^2+(r_3r_1\cos\beta)^2}+r_2r_3\cos\beta\\&=r_2r_3\cos\beta-\sqrt{r_1^2r_2^2+r_1^2r_3^2+2r_1^2r_2r_3\cos\beta}\end{aligned}

接下来,设 a=r2r3,b=r12r22+r12r32,c=2r12r2r3,t=cos⁡βa=r_2r_3,b=r_1^2r_2^2+r_1^2r_3^2,c=2r_1^2r_2r_3,t=\cos\beta,那么

σ=at−b+ct\sigma=at-\sqrt{b+ct}

这是一个关于 tt 的函数,我们大力求导得到

σ′=a−c2b+ct\sigma^\prime=a-\dfrac{c}{2\sqrt{b+ct}}

令 σ′>0\sigma^\prime>0,解得 t>c2−4a2ba2ct>\dfrac{c^2-4a^2b}{a^2c}。因此,t=c2−4a2ba2ct=\dfrac{c^2-4a^2b}{a^2c} 时 σ\sigma 取到最小值。

要注意一下 tt 是有取值范围 [−1,1][-1,1] 的,所以要把 tt 和 −1-1 取个 max⁡\max,和 11 取个 min⁡\min。

code:\texttt{code:}(代码里的 A 是式子里的 bb,B 是 cc,C 是 aa)

C++
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
//inline int max(int a,int b){return a>b?a:b;}
//inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

typedef long double ld;
int main()
{
	ld r1,r2,r3;
	cin>>r1>>r2>>r3;
	ld A=r1*r1*r2*r2+r1*r1*r3*r3,B=2*r1*r1*r2*r3,C=r2*r3;
	ld t=(B*B-4*C*C*A)/(4*B*C*C);
	if(t<-1.0f) t=-1.0f;if(t>1.0f) t=1.0f;
	if(A+B*t<0) t=-A/B;
	ld ans=-sqrt(A+B*t)+C*t;
	printf("%.1Lf",ans);
	return 0;
}
原文