周长公式为2*L+acos((L*L-W*W)/(L*L+W*W))*sqrt(L*L+W*W)。然后二分L或者W就行了。
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const double pi=3.14159265;
const double eps=1e-10;
double a,b;
int dcmp(double x)
{
if(fabs(x)<eps) return 0;
else return x<0?-1:1;
}
int main()
{
freopen("in.txt","r",stdin);
int kase=1;
while(~scanf("%lf : %lf",&a,&b))
{
cout<<"Case "<<kase++<<": ";
double L=0.0,R=200.0;
while(dcmp(L-R)<0)
{
double M=(L+R)/2;
double W=b*M/a;
double tmp=2*M+acos((M*M-W*W)/(M*M+W*W))*sqrt(M*M+W*W);
if(dcmp(tmp-400)>0) R=M;
else L=M;
}
printf("%.10f %.10f\n",L,b*L/a);
}
return 0;
}