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

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

            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.




            發(fā)現(xiàn)偶還是太水了。。。

            #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)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            国产精品久久久久…| 亚洲国产成人精品女人久久久 | 久久福利青草精品资源站免费| 精品久久久无码21p发布| 久久久久久精品无码人妻| 久久综合给久久狠狠97色| 精品国产一区二区三区久久久狼| 国产精品久久毛片完整版| 久久97久久97精品免视看| 777午夜精品久久av蜜臀| 久久国产乱子精品免费女| 思思久久99热免费精品6| 69SEX久久精品国产麻豆| 亚洲美日韩Av中文字幕无码久久久妻妇| 中文字幕无码精品亚洲资源网久久| a高清免费毛片久久| 国内高清久久久久久| 国产—久久香蕉国产线看观看 | 久久国产精品一区| 嫩草伊人久久精品少妇AV| 品成人欧美大片久久国产欧美... 品成人欧美大片久久国产欧美 | 久久精品九九亚洲精品| 久久成人18免费网站| 久久精品国产亚洲AV无码娇色| 香蕉久久AⅤ一区二区三区| 好久久免费视频高清| 奇米影视7777久久精品| 麻豆久久久9性大片| 久久久久亚洲AV无码专区网站| 久久精品无码午夜福利理论片| 欧美日韩久久中文字幕| 色婷婷久久久SWAG精品| 久久精品国产亚洲7777| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 国产精品久久一区二区三区| 精品久久人人爽天天玩人人妻| 日韩va亚洲va欧美va久久| 国产精品日韩欧美久久综合| 国产一级持黄大片99久久| 999久久久免费精品国产| 久久大香香蕉国产|