正题
大意
解题思路
沟谷定理可以用半径求出高度,然后暴力枚举就好了
公式:
ah=r2−(a/2)2−−−−−−−−−√∗2ah=r2−(a/2)2∗2
bh=r2−(b/2)2−−−−−−−−−√∗2bh=r2−(b/2)2∗2
然后计算两个的面积去掉重复的
S=a∗ah+b∗bh−a∗bS=a∗ah+b∗bh−a∗b
代码
#include<cstdio>
#include<cmath>
using namespace std;
double r,a,b,la,lb,rs,sum,maxs;
int main()
{scanf("%lf",&r);for (int i=1;i<2*r;i++){for (int j=1;j<2*r;j++){a=(double)i;b=(double)j;//转换sum=-a*b+sqrt(r*r-(a/2)*(a/2))*2*a+sqrt(r*r-(b/2)*(b/2))*2*b;//计算面积if (sum>maxs){maxs=sum;la=a;lb=b;//记录}}}printf("%0.lf\n%0.lf",la,lb);
}