• <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測試數據很弱,可能在其他oj上過不了,根據三角形相似得出以下關于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 閱讀(563) 評論(0)  編輯 收藏 引用 所屬分類: 貪心*二分
            <2012年4月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            伊人情人综合成人久久网小说| 亚洲色欲久久久综合网| 激情五月综合综合久久69| 久久精品亚洲男人的天堂| 国产亚洲精久久久久久无码77777| 俺来也俺去啦久久综合网| 久久性精品| 91精品国产综合久久香蕉| 囯产精品久久久久久久久蜜桃| 久久久久综合网久久| 青青草原综合久久大伊人| 国产精品欧美亚洲韩国日本久久| 久久综合九色综合网站| 久久精品国产第一区二区| 国产精品国色综合久久| 精品国产乱码久久久久软件| 国产成人综合久久精品尤物| 国产精品久久久久久一区二区三区| 色偷偷88欧美精品久久久 | 久久久久这里只有精品 | 日本亚洲色大成网站WWW久久| 久久精品无码专区免费青青| 午夜精品久久久久久影视777| 伊人丁香狠狠色综合久久| 久久综合综合久久综合| 久久国产色av免费看| 久久久久一级精品亚洲国产成人综合AV区 | 9999国产精品欧美久久久久久| 国产综合久久久久| 人人狠狠综合久久88成人| 久久九九兔免费精品6| 狠狠色丁香久久婷婷综合| 久久久久亚洲Av无码专| 97精品国产97久久久久久免费| 99久久精品免费看国产一区二区三区| 思思久久99热只有频精品66| 久久亚洲国产精品123区| 精品久久人人妻人人做精品| 久久精品国产一区二区三区| 久久综合九色综合精品| 久久综合久久综合九色|