• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 195,  comments - 30,  trackbacks - 0

            A narrow street is lined with tall buildings. An x foot long ladder is rested at the base of the building on the right side of the street and leans on the building on the left side. A y foot long ladder is rested at the base of the building on the left side of the street and leans on the building on the right side. The point where the two ladders cross is exactly c feet from the ground. How wide is the street?

             

            Input Specification

            Each line of input contains three positive floating point numbers giving the values of x, y, and c.

            Output Specification


            For each line of input, output one line with a floating point number giving the width of the street in feet, with three decimal digits in the fraction.

            Sample Input

            30 40 10
            12.619429 8.163332 3
            10 10 3
            10 10 1
            

            Sample Output

            26.033
            7.000
            8.000
            9.798
            

            joj測試數(shù)據(jù)很弱,可能在其他oj上過不了,根據(jù)三角形相似得出以下關(guān)于w的方程,解w,第一次用二分法,不錯。
            f(w) = c - sqrt((y*y-w*w)*(x*x-w*w))/(sqrt(y*y-w*w) + sqrt(x*x -w*w))

            #include<iostream>
            #include
            <cstdlib>
            #include
            <iomanip>
            #include
            <math.h>
            using namespace std;
            //f(w) = c - sqrt((y*y-w*w)*(x*x-w*w))/(sqrt(y*y-w*w) + sqrt(x*x -w*w))
              double func(double x,double y,double c)
              {
                
            double wdown=0.0,wup,w,fw;
                
            if(x>y)
                wup
            =y;
                
            else
                wup
            =x;
                w
            =wup/2.0;
                
            while(1)
                {
                    fw
            =c-sqrt((y*y-w*w)*(x*x-w*w))/(sqrt(y*y-w*w) + sqrt(x*-w*w));
                    
            if(fw>0.0001)
                     {
                            wup
            =w;
                            w
            =(wup+wdown)/2;
                     }
                    
            else
                    {
                        
            if(fw<-0.0001)
                        {
                            wdown
            =w;
                            w
            =(wup+wdown)/2;
                        }
                        
            else
                        {
                            
            return w;
                        }
                    }
                }
                    
               }
             
            int main()          
            {  
            //freopen("s.txt","r",stdin);
              
            //freopen("key.txt","w",stdout);
              double x,y,c;
            while( cin>>x>>y>>c)
            {
                cout
            <<fixed<<setprecision(3)<<func(x,y,c)<<endl;
            }

              
            //system("PAUSE");
              return   0;
              }

            posted on 2009-07-08 19:30 luis 閱讀(561) 評論(0)  編輯 收藏 引用 所屬分類: 貪心*二分
            <2012年12月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            色婷婷久久久SWAG精品| 精品久久久久久| 性做久久久久久久久久久| 欧美午夜A∨大片久久 | 日韩亚洲国产综合久久久| 99久久免费国产精品特黄| 久久免费的精品国产V∧ | 一本久道久久综合狠狠躁AV| 97久久国产露脸精品国产| 亚洲一区二区三区日本久久九| 一本色综合久久| 成人精品一区二区久久| 婷婷综合久久中文字幕蜜桃三电影| 久久97精品久久久久久久不卡| 久久久精品无码专区不卡| 欧美午夜精品久久久久免费视| 久久93精品国产91久久综合| 国内精品久久久久影院日本| 亚洲精品NV久久久久久久久久| 香港aa三级久久三级| 久久偷看各类wc女厕嘘嘘| 99精品国产免费久久久久久下载 | 久久久女人与动物群交毛片| 久久婷婷色综合一区二区| 久久综合九色综合精品| 久久九九精品99国产精品| 久久精品人妻中文系列| 少妇被又大又粗又爽毛片久久黑人| 色偷偷888欧美精品久久久| 狠狠色噜噜狠狠狠狠狠色综合久久| 亚洲va国产va天堂va久久| 久久婷婷午色综合夜啪| 国内精品伊人久久久影院| 亚洲精品无码久久久久AV麻豆| 久久天天躁狠狠躁夜夜2020老熟妇| 香蕉久久夜色精品国产小说| 青青国产成人久久91网| 亚洲国产精品热久久| 久久精品一区二区三区中文字幕 | 亚洲伊人久久综合影院| 欧美激情一区二区久久久|