Fork me on GitHub

hdu2438 几何推导+三分

不行我要再写一道三分题

没错就是这道题

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

网图。。。

我数模队友竟然推了一页公式。。。应该是机理分析比较适合吧。。。反正我看不懂哈哈哈哈

哦哦哦还有个花絮,你不能引用cmath之后

再全局一个y0,因为cmath里有y0这个变量好神奇

Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3659    Accepted Submission(s): 1530


Problem Description
Mr. West bought a new car! So he is travelling around the city.

One day he comes to a vertical corner. The street he is currently in has a width x, the street he wants to turn to has a width y. The car has a length l and a width d.

Can Mr. West go across the corner?
 

 

Input
Every line has four real numbers, x, y, l and w.
Proceed to the end of file.
 

 

Output
If he can go across the corner, print "yes". Print "no" otherwise.
 

 

Sample Input
10 6 13.5 4 10 6 14.5 4
 

 

Sample Output
yes no
 
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define eps 1e-6
#define ll long long
double x0,yy0,d0,l0;
double cal(double the){
    double x = x0 - d0/cos(the) - l0*sin(the);
    x = x/tan(the);
    return -x;
}
double sanfen_max(double left,double right){
    double l,r,lmid,rmid;
    l = left;
    r = right;
    while(r - l > eps){
        lmid = l + (r - l)/3;
        rmid = r - (r - l)/3;
        if(cal(lmid) > cal(rmid)) r = rmid;
        else l = lmid;
//        printf("%f %f\n",cal(lmid),cal(rmid));
    }
    return r;
}
int main(){
    while(scanf("%lf%lf%lf%lf",&x0,&yy0,&l0,&d0) != EOF){
        double res = sanfen_max(0+eps,3.1415926/2);
//        printf("%f\n",cal(res));
        if(cal(res) <= yy0) printf("YES");
        else printf("NO\n");
    }
    return 0;
}

 

posted @ 2018-04-12 15:18  梦想飞的菜鸟  阅读(288)  评论(0)    收藏  举报