题解:P6468 [COCI 2008/2009 #6] BAZEN
Charles_with_wkc · · 题解
前置知识
鸟头模型。
概述
本题为简单的几何题,但需要很强大的分类讨论能力。
分类讨论
-
a=0,b=0 -
a=250,b=0 -
a=0,b=250 -
a=125,b=125 -
a\ne0,b=0,a\le125 -
a\ne0,b=0,a>125 -
a=0,b\ne0,b\le125 -
a=0,b\ne0,b>125 -
a\ne0,b\ne0,a>b -
a\ne0,b\ne0,a<b 代码
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' double a,b,c1,c2,c3; signed main(){ // ios::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); cin>>a>>b; if(a==0&&b==0) cout<<"125.00 125.00"; else if(a==250) cout<<"0.00 125.00"; else if(b==250) cout<<"125.00 0.00"; else if(a==125&&b==125) cout<<"0.00 0.00"; else if(a==0&&b!=0&&b<=125){ c1=250.0-b; c2=250.0; c3=(1.0/2.0)/(c1/c2); printf("%.2lf %.2lf",250.0*c3,250.0-250.0*c3); return 0; } else if(a==0&&b!=0&&b>125){ c1=b; c2=250.0; c3=(1.0/2.0)/(c1/c2); printf("%.2lf 0.00",250.0*c3); return 0; } else if(a!=0&&b==0&&a<=125){ c1=250.0-a; c2=250.0; c3=(1.0/2.0)/(c1/c2); printf("%.2lf %.2lf",250.0-250.0*c3,250.0*c3); return 0; } else if(a!=0&&b==0&&a>125){ c1=a; c2=250.0; c3=(1.0/2.0)/(c1/c2); printf("0.00 %.2lf",250.0*c3); return 0; } else if(a!=0&&b!=0&&a>b){ c1=sqrt(a*a+(250.0-b)*(250.0-b)); c2=sqrt(250.0*250.0*2); c3=(1.0/2.0)/(c1/c2); printf("0.00 %.2lf",250.0-250.0*c3); return 0; } else if(a!=0&&b!=0&&a<b){ c1=sqrt((250.0-a)*(250.0-a)+b*b); c2=sqrt(250.0*250.0*2); c3=(1.0/2.0)/(c1/c2); printf("%.2lf 0.00",250.0-250.0*c3); return 0; } return 0; }