• <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 閱讀(1059) 評論(0)  編輯 收藏 引用


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


            亚洲乱码中文字幕久久孕妇黑人| 亚洲国产精品无码久久青草 | …久久精品99久久香蕉国产 | 精品国产乱码久久久久久1区2区 | 996久久国产精品线观看| 国产精品久久午夜夜伦鲁鲁| 国内精品伊人久久久久影院对白 | 一本久道久久综合狠狠躁AV| 久久婷婷五月综合成人D啪| 麻豆亚洲AV永久无码精品久久| 久久99热这里只有精品国产| 久久超乳爆乳中文字幕| 思思久久99热只有频精品66| 99久久国产综合精品麻豆| 伊人久久大香线蕉AV色婷婷色| 国产精品成人99久久久久 | 99久久er这里只有精品18| 日韩人妻无码精品久久免费一| 狠狠久久综合| 久久久久久伊人高潮影院| 久久久久久久久久免免费精品| 999久久久国产精品| 99热精品久久只有精品| 亚洲综合婷婷久久| 亚洲日本va午夜中文字幕久久| 精品久久久久久久久久久久久久久 | AV无码久久久久不卡蜜桃| 久久人做人爽一区二区三区| 无码精品久久久天天影视| 久久国产精品99精品国产| 色综合久久中文综合网| 久久久久久免费视频| 人妻精品久久久久中文字幕一冢本| 久久久老熟女一区二区三区| 99久久精品免费看国产| 精品国产乱码久久久久软件| 久久精品国产清自在天天线| 久久久久AV综合网成人| 无码精品久久一区二区三区| 9久久9久久精品| 少妇久久久久久久久久|