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

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋

            題目地址:
                     http://acm.hdu.edu.cn/showproblem.php?pid=2199
            題目描述:
                     
            Can you solve this equation?

            Time Limit: 
            2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
            Total Submission(s): 
            322    Accepted Submission(s): 148


            Problem Description
            Now,given the equation 
            8*x^4 + 7*x^3 + 2*x^2 + 3*+ 6 == Y,can you find its solution between 0 and 100;
            Now please 
            try your lucky.
             

            Input
            The first line of the input contains an integer T(
            1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);
             

            Output
            For each test 
            case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.
             

            Sample Input
            2
            100
            -4
             

            Sample Output
            1.6152
            No solution
            !

            題目分析:
            很明顯,這是一個2分搜索的題目, 但是注意下題目的數據!! 1e10 的實數!! 而且精度是要求在 0.0001 . 所以就算是2分數據量依舊比較大,如果用
            通常的遞歸方法嗎很遺憾 , RE了.............  沒辦法, 只能循環了.
            下面的是遞歸 RE 的代碼 :
            #include <iostream>
            #include <cmath>
            using namespace std;
            #define POW(x) ( (x) * (x) )
            #define POW3(x) ( POW(x) * (x) )
            #define POW4(x) ( POW(x) * POW(x) )
            double y = 0;
            bool douEql ( double a,double b )
            {
            if ( fabs( a - b ) <= 1e-6  )
            return  true;
            return false;
            }
            double cal ( double n )
            {
            return 8.0 * POW4(n) + 7 * POW3(n) + 2 * POW(n) + 3 * n + 6 ;
            }
            double biSearch ( double l, double r )
            {
            if ( douEql ( l,r ) )
            {
            if ( douEql ( y, cal ( l ) ) )
            return l;
            return -1;
            }
            double mid = ( l + r ) / 2.0;
            if ( douEql ( y, cal ( mid ) ) )
            return mid;
            else if ( cal ( mid ) > y )
            return biSearch ( l,mid - 0.0001 );
            else
            return biSearch ( mid + 0.0001, r );
            }
            int main ()
            {
            int T;
            scanf ( "%d",&T );
            while ( T -- )
            {
            scanf ( "%lf",&y );
            if ( cal(0) >= y && cal(100) <= y )
            {
            printf ( "No solution!\n" );
            continue;
            }
            double res = biSearch ( 0.0, 100.0 );
            if ( res == -1 )
            printf ( "No solution!\n" );
            else
            printf ( "%.4lf\n",res );
            }
            return 0;
            }

            AC代碼如下:
            MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋

            #include 
            <iostream>
            #include 
            <cmath>
            using namespace std;
            #define POW(x) ( (x) * (x) )
            #define POW3(x) ( POW(x) * (x) )
            #define POW4(x) ( POW(x) * POW(x) )
            double y = 0;
            double cal ( double n )
            {
                   
            return 8.0 * POW4(n) + 7 * POW3(n) + 2 * POW(n) + 3 * n + 6 ;
            }
            int main ()
            {
                
            int T;
                scanf ( 
            "%d",&T );
                
            while ( T -- )
                {
                      scanf ( 
            "%lf",&y );
                      
            if ( cal(0> y || cal(100< y )
                      {
                           printf ( 
            "No solution!\n" );
                           
            continue;
                      }
                      
            double l = 0.0, r = 100.0,res = 0.0;
                      
            while ( r - l > 1e-6 )
                      {
                            
            double mid = ( l + r ) / 2.0;
                            res 
            = cal ( mid );
                            
            if ( res > y )
                                 r 
            = mid - 1e-6;    
                            
            else 
                                 l 
            = mid + 1e-6;
                      }
                      printf ( 
            "%.4lf\n",( l + r ) / 2.0 ); 
                }
                
            return 0
            }
            亚洲美日韩Av中文字幕无码久久久妻妇 | 久久成人国产精品| 久久久亚洲欧洲日产国码是AV | 久久久无码精品亚洲日韩京东传媒| 国产69精品久久久久久人妻精品| 国产亚洲欧美成人久久片 | 久久夜色撩人精品国产| 久久精品水蜜桃av综合天堂| 久久久精品国产Sm最大网站| 国产∨亚洲V天堂无码久久久| 日韩久久久久中文字幕人妻| 成人免费网站久久久| 久久人人爽人人爽AV片| 色成年激情久久综合| 久久久久久亚洲Av无码精品专口| 一级做a爰片久久毛片看看| 国产精品综合久久第一页| 国产成人精品久久免费动漫| 久久综合精品国产二区无码| 久久精品国产亚洲5555| 久久久久国产精品| AV无码久久久久不卡网站下载| 亚洲乱码中文字幕久久孕妇黑人| 亚洲国产成人精品久久久国产成人一区二区三区综 | 精品午夜久久福利大片| 国产精品久久久久jk制服| 99久久香蕉国产线看观香| 女人高潮久久久叫人喷水| 久久一区二区三区99| 色偷偷91久久综合噜噜噜噜| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | yy6080久久| 亚洲国产另类久久久精品黑人| 亚洲中文字幕无码久久综合网| 婷婷综合久久中文字幕蜜桃三电影| 亚洲精品乱码久久久久久中文字幕 | 久久无码AV一区二区三区| 人妻中文久久久久| 精品伊人久久久| 色婷婷综合久久久久中文| 久久精品黄AA片一区二区三区|