【HDU 2438】 Turn the corner

xiaoxiao2021-02-28  94

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2438 题意: 给出多组x,y,l,d,回答能否通过 题解: 图好丑啊啊啊啊啊啊啊啊!!!!! 数学题。。。。。 难度主要在于列个函数关系式 只要保证(PH)max<=y即可 然后证明这个函数在(0,π/2)是单峰的 蒟蒻懒(bu)得(hui)证明,只好刷表~(≧▽≦)/~啦啦啦 然后愉快地套一个三分就OK了 暴力刷表结果如下orz 然后代码

#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; double x,y,l,w; const double eps=1e-6; const double pi=acos(-1.0); double calc(double angle) { return (-x+l*sin(angle)+w/cos(angle))/tan(angle); } int main() { while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF) { double ll=0,rr=pi/2,midx,midy; while(rr-ll>eps) { midx=(2*ll+rr)/3; midy=(ll+2*rr)/3; if(calc(midx)<calc(midy)) ll=midx; else rr=midy; } if(calc(ll)<=y) printf("yes\n"); else printf("no\n"); } return 0; }
转载请注明原文地址: https://www.6miu.com/read-48520.html

最新回复(0)