• <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>
            posts - 195,  comments - 30,  trackbacks - 0
            #include<iostream>
            using namespace std;
            int num[100];
            int a,s;
            int MAX;
            void search(int i,int sum)
            {
                 
            int j;
                 
            if(i==a)//到達終點的處理
                 {
                 
            if(sum*(s-sum)>MAX)
                    MAX
            =sum*(s-sum);
                 }
                 
            else
                 
            for(j=0;j<2;j++)//各個支路
                 {
                      
            //理論上應當添加條件判斷
                      search(i+1,sum+j*num[i-1]);
                 }
            }
            int main()
            {
               
            int b,c,sum;
               
            while(cin>>a)
               {       
                     sum
            =0;
                     s
            =0;
                     MAX
            =0;       
                     
            for(b=0;b<a;b++)
                     {
                         cin
            >>num[b];
                         s
            +=num[b];            
                     }
                     search(
            0, sum);//從這里開始
                     cout<<MAX<<endl;
                            
               } 
            }
            還有一點啟發,max不能用,可以用MAX,無需記錄

            There are multiple test cases, the first line of each test case is a integer n. (2<=n<=20) The next line have n integers (every integer in the range [1,1000]). We can divide these n integers into two parts and get the sum of the integers in these two parts, define them as sumA and sumB. Please calc the max number of sumA*sumB and output it in a single line.

            Sample Input

            3
            5 3 7
            2
            4 9
            

            Sample Output

            56
            36
            

            Hint

            (5,3),(7)  sumA=8  sumB=7  sumA*sumB=56
            (5),(3,7)  sumA=5  sumB=10 sumA*sumB=50
            (3),(5,7)  sumA=3  sumB=12 sumA*sumB=36
            (),(3,5,7) sumA=0  sumB=15 sumA*sumB=0
            The max is 56.
            
            posted on 2009-05-12 22:18 luis 閱讀(324) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲精品国产美女久久久| 午夜不卡888久久| 伊人久久大香线蕉无码麻豆| 日日狠狠久久偷偷色综合0| 蜜桃麻豆www久久国产精品| 香蕉久久av一区二区三区| 久久精品国产99国产精偷| 色99久久久久高潮综合影院| 久久婷婷五月综合97色一本一本| 91久久精品国产免费直播| 日韩精品久久久久久久电影| 国产精品久久久久影视不卡| 午夜精品久久久久久| 精品久久久久久国产| 狠狠精品久久久无码中文字幕| 久久精品这里热有精品| 国产69精品久久久久观看软件 | 久久精品人妻中文系列| 久久天堂电影网| 国产成人久久激情91| 久久久久久久久久久久久久| 欧洲国产伦久久久久久久 | 国产亚洲美女精品久久久久狼| 日韩美女18网站久久精品| 国产69精品久久久久99| 精品国际久久久久999波多野| 精品伊人久久久| 三级韩国一区久久二区综合 | 最新久久免费视频| 久久99精品国产麻豆婷婷| 国产日韩欧美久久| 99久久精品免费看国产一区二区三区| 精品久久久无码人妻中文字幕| 久久久久九国产精品| 久久AⅤ人妻少妇嫩草影院| 精品水蜜桃久久久久久久| 91精品国产91热久久久久福利| 91麻豆精品国产91久久久久久| 久久精品国产精品亚洲精品| 久久中文字幕一区二区| 91精品国产91久久久久久蜜臀|