• <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 閱讀(561) 評論(0)  編輯 收藏 引用 所屬分類: 貪心*二分
            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            91精品国产高清久久久久久91 | 国产国产成人久久精品| 久久天堂AV综合合色蜜桃网| 久久精品国产网红主播| 久久精品这里只有精99品| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 精品久久香蕉国产线看观看亚洲| 国产成人久久精品区一区二区| segui久久国产精品| 囯产极品美女高潮无套久久久| 国产精品久久久久久福利漫画| 亚洲精品无码久久久| 国产精品一区二区久久精品| 久久久亚洲裙底偷窥综合| 99久久精品费精品国产 | 日本久久中文字幕| 久久精品无码午夜福利理论片| 九九久久精品国产| 国产Av激情久久无码天堂| 国产精品久久久久久久人人看 | 色综合久久无码中文字幕| 狠狠色丁香婷婷综合久久来来去| 亚洲av日韩精品久久久久久a| 久久精品国产亚洲一区二区三区| 久久婷婷五月综合国产尤物app| 无码8090精品久久一区| 久久精品国产99久久香蕉| 久久久久久a亚洲欧洲aⅴ| 久久久久亚洲Av无码专| 久久免费看黄a级毛片| 久久久久久久97| 久久久这里有精品| 亚洲国产成人久久综合区| 久久精品无码一区二区三区日韩| 久久久久久久尹人综合网亚洲 | 久久99精品国产麻豆| 人妻无码αv中文字幕久久琪琪布| 日日狠狠久久偷偷色综合免费| 久久久久成人精品无码| 亚洲Av无码国产情品久久| 少妇人妻综合久久中文字幕|