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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久男人Av资源网站无码软件| 国产亚洲欧美成人久久片| 婷婷久久综合| 久久精品无码一区二区WWW| 性欧美丰满熟妇XXXX性久久久 | 久久国产成人精品国产成人亚洲| 亚洲综合婷婷久久| 中文字幕人妻色偷偷久久| 久久国产乱子伦免费精品| 精品乱码久久久久久夜夜嗨| 久久久国产打桩机| 久久93精品国产91久久综合| 无码精品久久久天天影视| 久久久久婷婷| 99久久国产亚洲高清观看2024| 久久精品国产亚洲AV蜜臀色欲| 一本大道加勒比久久综合| 亚洲综合精品香蕉久久网| 久久精品18| 93精91精品国产综合久久香蕉 | 久久这里只有精品久久| 国产成人精品三上悠亚久久| 国产激情久久久久影院小草| 99精品国产99久久久久久97 | 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久亚洲精品成人AV| 久久人人爽人人爽人人片AV麻豆| 久久久久无码精品国产不卡| 亚洲午夜福利精品久久| 国内精品伊人久久久久| 亚洲中文字幕无码一久久区| 亚洲日本久久久午夜精品| 久久久久18| 亚洲国产精品无码久久青草| 国产精品丝袜久久久久久不卡| 久久婷婷久久一区二区三区| 久久99国内精品自在现线| 久久精品人人做人人爽97| 久久久久久久久无码精品亚洲日韩 | AV色综合久久天堂AV色综合在| 国内精品久久久久影院薰衣草|