很常规的一道初中几何题 其实这道题本质上就是用含x,y,z的代数式表示AP,主要运用相似三角形,证明过程如下图所示
如果你不会相似三角形,点这里
(洛谷图床有些糊,如果真的看不清可以另存为到本地看)
最后求出AP的关系式之套进代码里即可
注意:
要开double因为带有根号所以会有小数的情况
由于是ATcoder,所以要换行输出
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);//加速cin,cout(其实针对这题而言没必要)
int x,y,z;
cin>>x>>y>>z;
double ans;//开double
ans=(2.0*x*z)/(sqrt(x*x+y*y)+z);
printf("%.15f\n",ans);//保留15位小数输出
return 0;
}
