这个代码样例全过WA0,求调。
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
double l,r,x1,y1,x2,y2,x3,y3;
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&l,&r,&x1,&y1,&x2,&y2,&x3,&y3);
double ans=0x3f3f3f3f3f3f3f3f;
for(double i=l;i<=r+0.01;i+=0.01){
double xe=abs(x1-x3)*(1-i)+x1,ye=abs(y1-y3)*(1-i)+y1;
double xf=abs(x1-x2)*i+x1,yf=abs(y1-y2)*i+y1;
double xd=abs(x2-x3)*(1-i)+x3,yd=abs(y2-y3)*i+y2;
//printf("%.12lf %.12lf\n%.12lf %.12lf\n%.12lf %.12lf\n",xe,ye,xf,yf,xd,yd);
double A=sqrt((xe-xd)*(xe-xd)+(ye-yd)*(ye-yd));
double B=sqrt((xd-xf)*(xd-xf)+(yd-yf)*(yd-yf));
double C=sqrt((xf-xe)*(xf-xe)+(yf-ye)*(yf-ye));
double p=(A+B+C)/2;
ans=min(ans,sqrt(p*(p-A)*(p-B)*(p-C)));
//printf("%.2lf %.12lf %.12lf %.12lf %.12lf\n",i,A,B,C,sqrt(p*(p-A)*(p-B)*(p-C)));
}
printf("%.12lf",ans);
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
double l,r,x1,y1,x2,y2,x3,y3;
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&l,&r,&x1,&y1,&x2,&y2,&x3,&y3);
double ans=0x3f3f3f3f3f3f3f3f;
for(double i=l;i<=r+0.01;i+=0.01){
double xe=abs(x1-x3)*(1-i)+x1,ye=abs(y1-y3)*(1-i)+y1;
double xf=abs(x1-x2)*i+x1,yf=abs(y1-y2)*i+y1;
double xd=abs(x2-x3)*(1-i)+x3,yd=abs(y2-y3)*i+y2;
//printf("%.12lf %.12lf\n%.12lf %.12lf\n%.12lf %.12lf\n",xe,ye,xf,yf,xd,yd);
double A=sqrt((xe-xd)*(xe-xd)+(ye-yd)*(ye-yd));
double B=sqrt((xd-xf)*(xd-xf)+(yd-yf)*(yd-yf));
double C=sqrt((xf-xe)*(xf-xe)+(yf-ye)*(yf-ye));
double p=(A+B+C)/2;
ans=min(ans,sqrt(p*(p-A)*(p-B)*(p-C)));
//printf("%.2lf %.12lf %.12lf %.12lf %.12lf\n",i,A,B,C,sqrt(p*(p-A)*(p-B)*(p-C)));
}
printf("%.12lf",ans);
return 0;
}
这个代码样例没过WA20?
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
double l,r,x1,y1,x2,y2,x3,y3;
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&l,&r,&x1,&y1,&x2,&y2,&x3,&y3);
double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
double c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
double ans=0x3f3f3f3f;
for(double i=l;i<=r+0.01;i+=0.01){
double A=a*i;
double B=b*i;
double C=c*i;
A=max(a-A,A);
B=max(b-B,B);
C=max(c-C,C);
double p=(A+B+C)/2;
ans=min(ans,sqrt(p*(p-A)*(p-B)*(p-C)));
//printf("%.2lf %.12lf %.12lf %.12lf %.12lf\n",i,A,B,C,sqrt(p*(p-A)*(p-B)*(p-C)));
}
printf("%.12lf",ans);
return 0;
}