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

            The Fourth Dimension Space

            枯葉北風寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令

            Topcoder 463 Div 2 1000

            Problem Statement

                 Taro and Hanako are playing a game called Nisoku, which is played as follows. Initially, there is a pile of cards. Each card contains a real number between 1.5 and 10.0, inclusive. You are given a vector <double> cards, the i-th element of which is the number written on the i-th card.

            Repeat the following step until there is only one card left in the pile: Remove any two cards from the pile, and add one new card to the pile. Write either a+b or a*b on the new card, where a and b are the numbers written on the two cards that were removed.

            Return the maximal possible number written on the final card in the pile.

            Definition

                
            Class: Nisoku
            Method: theMax
            Parameters: vector <double>
            Returns: double
            Method signature: double theMax(vector <double> cards)
            (be sure your method is public)
                

            Notes

            - Your return value must have an absolute or relative error less than 1e-9.

            Constraints

            - cards will contain between 2 and 50 elements, inclusive.
            - Each element of cards will be between 1.5 and 10.0, inclusive.

            Examples

            0)
                
            {5, 8}
            Returns: 40.0
            5 * 8 = 40.
            1)
                
            {1.5, 1.8}
            Returns: 3.3
            1.5 + 1.8 = 3.3.
            2)
                
            {8.26, 7.54, 3.2567}
            Returns: 202.82857868
            3)
                
            {1.5, 1.7, 1.6, 1.5}
            Returns: 9.920000000000002
            4)
                
            {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
                                                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
                                                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
                                                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
                                                10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
            Returns: 1.0E50
            The answer can be extremely big.




            發現偶還是太水了。。。

            #include<iostream>
            #include
            <algorithm>
            #include
            <vector>
            using namespace std;



            class Nisoku
            {
            public:
                
            double theMax(vector<double>cards)
                
            {    
                    
            int i,j;
                    sort(cards.begin(),cards.end());
                    
            double ans=0;
                    
            for(i=0;i<=cards.size();i+=2)
                    
            {
                        
            double p=1;
                        
            for(j=0;j<i/2;j++)
                            p
            *=(cards[j]+cards[i-1-j]);
                        
            for(j=i;j<cards.size();j++)
                            p
            *=cards[j];
                        ans
            =max(ans,p);
                    }

                    
            return ans;
                }

            }
            ;

            誰能證明下這份代碼的正確性?

            posted on 2010-03-02 22:27 abilitytao 閱讀(1061) 評論(0)  編輯 收藏 引用

            精品久久久噜噜噜久久久| 国产精品无码久久四虎| 无码人妻精品一区二区三区久久久| 中文成人久久久久影院免费观看 | 国产成人无码精品久久久性色| 久久这里都是精品| 久久精品国产亚洲av日韩| 久久中文字幕一区二区| 青青热久久国产久精品| 国产综合久久久久久鬼色| 久久99精品国产99久久6男男| 国产91久久综合| 精品综合久久久久久97| 久久精品九九亚洲精品天堂| 日本加勒比久久精品| 国产一级做a爰片久久毛片| 久久亚洲sm情趣捆绑调教| 久久福利青草精品资源站免费| 久久久久这里只有精品| 久久99精品久久只有精品| 久久综合五月丁香久久激情| 久久99精品久久久久久hb无码| 精品无码人妻久久久久久| 久久亚洲精品成人av无码网站| 少妇被又大又粗又爽毛片久久黑人| 久久狠狠爱亚洲综合影院| 久久精品国产色蜜蜜麻豆| 97久久精品无码一区二区天美| 一本色道久久综合亚洲精品| 国产午夜电影久久| .精品久久久麻豆国产精品| 中文字幕日本人妻久久久免费| 久久伊人影视| 日本加勒比久久精品| 久久99精品久久久久久野外| 国产精品99久久精品| 久久精品人人槡人妻人人玩AV| 77777亚洲午夜久久多喷| 久久精品国产色蜜蜜麻豆| 综合久久给合久久狠狠狠97色 | 国产AⅤ精品一区二区三区久久|