• <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)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            香蕉99久久国产综合精品宅男自| 97久久香蕉国产线看观看| 久久精品国产99国产精品澳门| 精品熟女少妇a∨免费久久| 久久精品99久久香蕉国产色戒 | 99久久精品无码一区二区毛片| 亚洲成人精品久久| 亚洲精品国精品久久99热| 婷婷久久香蕉五月综合加勒比| 国产精品久久久久影院色 | 国产激情久久久久影院老熟女免费 | 欧美性猛交xxxx免费看久久久| 99久久这里只精品国产免费| 欧美午夜精品久久久久免费视| 久久久精品一区二区三区| 少妇被又大又粗又爽毛片久久黑人 | 国产成人精品三上悠亚久久| 狠狠狠色丁香婷婷综合久久俺| 亚洲精品美女久久久久99小说 | 欧美777精品久久久久网| 亚洲国产成人久久一区久久| 国内精品久久久久久99| 蜜桃麻豆WWW久久囤产精品| 久久九九亚洲精品| 久久久一本精品99久久精品88| 亚洲精品久久久www| 91麻豆精品国产91久久久久久| 日韩乱码人妻无码中文字幕久久| 久久久久亚洲AV成人网| 久久精品国产一区二区三区日韩| 中文字幕精品无码久久久久久3D日动漫| 青青草国产精品久久久久| 欧美大香线蕉线伊人久久| 久久人人爽人人爽人人片AV高清| 久久久久亚洲精品无码网址| 一本大道久久a久久精品综合| 久久人妻少妇嫩草AV无码专区| 亚洲va国产va天堂va久久| 2021国内久久精品| 久久精品国产亚洲AV影院| 一本色综合久久|