Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
60435 | wangjiajian | S1 | C++ | 解答错误 | 50 | 183 MS | 188 KB | 2047 | 2022-10-15 11:36:32 |
#include <cstdio> #include <cmath> using namespace std; bool jibo[4]; int zuoxia, youshang, aim; double T, a, b, c, d, e, f, g; double K, B, Y, X, realY, zuizuo, zuiyou, zuishang, zuixia; inline double mx(double i, double j) { return (i>j ? i:j); } inline double mn(double i, double j) { return (i<j ? i:j); } inline double qiujuli(double fir, double sec, double thi, double fou) { return sqrt(abs(fir-thi)*abs(fir-thi)+abs(sec-fou)*abs(sec-fou)); } int main() { scanf("%lf", &T); while(T--) { zuoxia = youshang = aim = 0; jibo[0] = jibo[1] = jibo[2] = jibo[3] = 0; scanf("%lf%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f, &g); zuizuo = mn(mn(a,c),e); zuiyou = mx(mx(a,c),e); zuixia = mn(mn(b,d),f); zuishang = mx(mx(b,d),f); double juxing = (zuiyou-zuizuo)*(zuishang-zuixia); juxing -= (double)abs(a-c)*abs(b-d)/2.0; juxing -= (double)abs(a-e)*abs(b-f)/2.0; juxing -= (double)abs(c-e)*abs(d-f)/2.0; if(zuizuo==a && zuixia==b) zuoxia = 1; else if(zuizuo==c && zuixia==d) zuoxia = 2; else if(zuizuo==e && zuixia==f) zuoxia = 3; if(zuiyou==a && zuishang==b) youshang = 1; else if(zuiyou==c && zuishang==d) youshang = 2; else if(zuiyou==e && zuishang==f) youshang = 3; if(zuoxia && youshang) { jibo[zuoxia] = jibo[youshang] = 1; for(int i=1; i<=3; i++) { if(jibo[i] == 0) { aim = i; break; } } if(aim == 1) X=a, realY=b; else if(aim == 2) X=c, realY=d; else if(aim == 3) X=e, realY=f; K = (zuishang-zuixia)/(zuiyou-zuizuo); // (x1-x2)k=(y1-y2) B = zuishang-K*zuiyou; // y1=k*x1+b Y = K*X+B; if(Y > realY) juxing -= (zuiyou-X)*(realY-zuixia); else juxing -= (X-zuizuo)*(zuishang-realY); } printf("%.2lf %.2lf\n", juxing*2.0/qiujuli(a,b,c,d)-g, mx(qiujuli(a,b,e,f),qiujuli(c,d,e,f))+g); } return 0; }