• <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>
            隨筆 - 87  文章 - 279  trackbacks - 0
            <2006年8月>
            303112345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 218039
            • 排名 - 117

            最新評論

            閱讀排行榜

            評論排行榜

            Crossed ladders
            Time Limit:1000MS? Memory Limit:65536K
            Total Submit:1837 Accepted:605

            Description
            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
            Each line of input contains three positive floating point numbers giving the values of x, y, and c.

            Output
            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
            

            Source
            The UofA Local 2000.10.14

            My Code:

            #include? < iostream >
            #include?
            < algorithm >
            #include?
            < cmath >
            #include?
            < iomanip >
            using ? namespace ?std;

            void ?round( double ?x,? double ?y,? double ?h)?
            {
            ????
            double ?s1,?s2,?s;
            ????
            double ?t,?beg,?end;
            ????
            if ?(x? == ?y)? {
            ????????s?
            = ?sqrt(x * x - 4 * h * h);
            ????}
            ? else ? {
            ????????
            if ?(y? < ?x)? {
            ????????????swap(x,?y);
            ????????}

            ????????beg?
            = ? 0 ;
            ????????end?
            = ?x;
            ????????s?
            = ?(beg? + ?end)? / ? 2 ;
            ????????t?
            = ? 1 ? / ?sqrt(x * x - s * s)? + ? 1 ? / ?sqrt(y * y - s * s);
            ????????
            while ?(fabs(t - 1 / h) > 0.000000001 )? {
            ????????????
            if ?(t? < ? 1 / h)? {
            ????????????????beg?
            = ?s;
            ????????????????s?
            = ?(beg? + ?end)? / ? 2 ;
            ????????????}
            ? else ? if ?(t? > ? 1 / h)? {
            ????????????????end?
            = ?s;
            ????????????????s?
            = ?(beg? + ?end)? / ? 2 ;
            ????????????}
            ? else ? {
            ????????????????
            break ;
            ????????????}

            ????????????t?
            = ? 1 ? / ?sqrt(x * x - s * s)? + ? 1 ? / ?sqrt(y * y - s * s);
            ????????}

            ????}

            ????cout?
            << ?setiosflags(ios:: fixed )? << ?setprecision( 3 )? << ?s? << ?endl;
            }


            int ?main()?
            {?
            ????
            double ?x,?y,?h;
            ????
            while ?(cin? >> ?x? >> ?y? >> ?h)? {
            ????????round(x,?y,?h);
            ????}

            ????
            return ? 0 ;
            }

            posted on 2006-05-08 21:24 閱讀(735) 評論(0)  編輯 收藏 引用 所屬分類: 算法&ACM
            日本久久久久亚洲中字幕| 欧美伊人久久大香线蕉综合| 国产精品久久国产精麻豆99网站| 无码人妻精品一区二区三区久久| 一级做a爰片久久毛片16| 久久综合色区| 中文字幕成人精品久久不卡| 久久人妻无码中文字幕| 91精品国产91久久| 色婷婷综合久久久久中文| 日韩va亚洲va欧美va久久| 国产精品久久久久久久久免费| 四虎国产精品成人免费久久| 狠狠色丁香婷婷久久综合不卡| 97精品伊人久久大香线蕉| 国产69精品久久久久9999| 久久综合国产乱子伦精品免费| 久久青青草原精品国产不卡| 国产精品禁18久久久夂久| 热re99久久精品国99热| 2021国内精品久久久久久影院| 日韩亚洲欧美久久久www综合网 | 久久美女人爽女人爽| 无码久久精品国产亚洲Av影片| 亚洲欧美成人久久综合中文网 | 亚洲av成人无码久久精品| 伊人久久大香线蕉AV一区二区 | 国产亚洲婷婷香蕉久久精品| 国产偷久久久精品专区 | 亚洲?V乱码久久精品蜜桃| 国产激情久久久久影院小草| 久久久久中文字幕| 99久久99久久精品国产片果冻 | 久久青草国产精品一区| 久久这里只有精品久久| 91精品国产高清久久久久久国产嫩草 | 欧美午夜A∨大片久久| 伊人久久一区二区三区无码| 超级97碰碰碰碰久久久久最新| 久久精品国产亚洲AV久| 久久婷婷五月综合97色一本一本|