• <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 閱讀(325) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2011年4月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            色婷婷噜噜久久国产精品12p| 精品免费tv久久久久久久| 久久精品成人一区二区三区| 亚洲日本va午夜中文字幕久久| 国内精品久久久久影院薰衣草| 亚洲色大成网站www久久九| 97久久超碰国产精品2021| 久久99国产精品成人欧美| 99久久国产宗和精品1上映| 久久精品国产精品亚洲精品| 日本亚洲色大成网站WWW久久| 国产精品美女久久久久| 伊人久久大香线蕉无码麻豆| 久久亚洲国产午夜精品理论片 | 久久青草国产精品一区| 久久国内免费视频| 久久er国产精品免费观看8| 久久亚洲精品无码AV红樱桃| 一本色道久久88综合日韩精品 | 亚洲国产精品成人久久蜜臀 | 久久美女网站免费| 浪潮AV色综合久久天堂| 久久精品综合网| 四虎亚洲国产成人久久精品| 狠狠色综合网站久久久久久久| 久久久久久夜精品精品免费啦| 日韩欧美亚洲综合久久| 久久久久亚洲AV成人网人人软件| A狠狠久久蜜臀婷色中文网| 影音先锋女人AV鲁色资源网久久 | 久久免费大片| 久久综合视频网站| 久久精品国产色蜜蜜麻豆| 国产成人久久精品麻豆一区| 久久综合九色综合欧美狠狠| AAA级久久久精品无码片| 国产成人综合久久综合| 99久久99这里只有免费费精品| 日韩精品久久久久久久电影蜜臀| 久久久精品国产免大香伊 | 九九精品99久久久香蕉|