青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 195,  comments - 30,  trackbacks - 0
After culling his most favorite fruits from the trees in an orchard,Keen AS, a mischievous monkey, is confused of the way in which he can combine these piles of fruits into one in the most laborsaving manner. Each turn he can merely combine any two piles into a larger one. Obviously, by combining N-1 times for N piles of fruits, one pile results eventually. It always takes AS a certain quantity of units of stamina, which equals to the sum of the amounts of fruits in each of the two piles combined, to complete a combination. For instance, given three piles of fruits, containing 1, 2, and 9 fruits respectively, the combination of 1 and 2 would cost 3=1+2 units of stamina, and two piles-3 and 9-are resulted; finally, combining them would cost another 12=3+9 units of stamina, and the total units of stamina taken in the whole procedure is 15=3+12. Surely there are many a possible means to combine these three piles; however, it can be proved that 15 is the minimum amount of units of stamina in demand, and that is what your program is required to do. in this problem ,the fruits are put in a strait line. A pile of fruits 'P' can only combined with the rightest pail on the left of P or the leftest on the right of P, and the united pile will at the position of the bigger one.

Input

The input file consists of many test cases. The first line contains an integer N (<=100), indicating the number of piles, and the second line contains N integers, each of which represents the amount of fruits in a pile. no integer will more than 10000, the sequence of integer also means the location of the piles.

Output

Your program should print the minimum amount of units of stamina that are required to combine these piles of fruits into one on request.

Sample Input

3
1 2 9

Sample Output

15

典型的石子合并問題。
#include<stdio.h>
int a[101][101],sum[101];
int stone[101];
int main()
{
    int n,i,j,k,flag,l,t;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=1;i<=n;i++)
        scanf("%d",&stone[i]);
        sum[0]=0;
        for(i=1;i<=n;i++)
        {
            sum[i]=sum[i-1]+stone[i];      
            a[i][i]=0;
        }
        for(l=1;l<=n-1;l++)
        for(i=1;i<=n-l;i++)
        {
            flag=0;
            j=i+l;
            for(k=i;k<j;k++)                              
            {
                t=a[i][k]+a[k+1][j]+sum[j]-sum[i-1];
                if(!flag)
                {
                    flag=1;
                    a[i][j]=t;
                }
                else if(t<a[i][j])
                a[i][j]=t;
            }
        }
        printf("%d\n",a[1][n]);
    }
    return 0;
}
posted on 2009-06-30 21:01 luis 閱讀(504) 評論(0)  編輯 收藏 引用 所屬分類: 動態(tài)規(guī)劃
<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用鏈接

留言簿(3)

隨筆分類

隨筆檔案

文章分類

文章檔案

友情鏈接

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产亚洲制服色| 欧美一区二区三区四区在线 | 亚洲啪啪91| 日韩视频在线观看免费| 99视频精品在线| 欧美中文日韩| 欧美成人一区二区| 91久久久久久国产精品| 亚洲韩国日本中文字幕| 一区二区三区久久网| 久久国产日韩| 99视频精品| 欧美一区二区成人| 永久久久久久| 欧美一区二区高清| 亚洲欧洲日韩综合二区| 国产精品高潮呻吟视频| 亚洲国产欧美一区二区三区丁香婷| 欧美成人免费播放| 欧美片网站免费| 狠狠色综合色区| 午夜精品美女久久久久av福利| 免费在线播放第一区高清av| 中国日韩欧美久久久久久久久| 欧美sm视频| 欧美午夜精品伦理| 亚洲欧洲一区二区在线播放| 亚洲另类视频| 免费观看在线综合| 亚洲欧美日韩系列| 9i看片成人免费高清| 国产小视频国产精品| 亚洲欧美日韩系列| 女生裸体视频一区二区三区| 欧美在线黄色| 欧美日韩一区二区免费视频| 日韩亚洲欧美成人一区| 欧美一区二区视频观看视频| 亚洲免费观看视频| 亚洲精品麻豆| 欧美日本三级| 久久久久一本一区二区青青蜜月| 亚洲婷婷综合久久一本伊一区| 欧美精品一区二区三| 久久久久久久性| 久久免费精品日本久久中文字幕| 国产精品日韩在线一区| 亚洲综合二区| 亚洲午夜精品久久| 亚洲精品中文字幕在线| 欧美在线视频免费| 一区在线免费观看| 欧美激情1区| 欧美激情女人20p| 亚洲特色特黄| 亚洲欧美日韩国产综合在线| 国产片一区二区| 老司机一区二区| 欧美暴力喷水在线| 亚洲综合另类| 欧美日韩喷水| 亚洲精品免费一二三区| 亚洲精品久久久一区二区三区| 99re亚洲国产精品| 国产精品免费视频xxxx| 久久一二三四| 欧美人在线观看| 亚洲欧洲精品一区二区三区| 亚洲国产精品一区二区第四页av| 亚洲精品小视频| 99在线热播精品免费| 牛牛国产精品| 亚洲精品国产精品国自产观看| 亚洲精品人人| 欧美日本不卡视频| 一区二区三区产品免费精品久久75| 国产午夜精品全部视频播放| 欧美一二三区在线观看| 久久精品欧美日韩| 伊人成人开心激情综合网| 久久综合给合| 欧美主播一区二区三区| 国产偷久久久精品专区| 欧美在线91| 欧美高清不卡| 一区二区欧美激情| 国产精品影音先锋| 日韩性生活视频| 午夜精品999| 国内精品福利| 午夜精品久久久久久久久| 久久精品成人一区二区三区| 一区二区在线不卡| 欧美精品123区| 亚洲男女自偷自拍| 亚洲欧美亚洲| 一色屋精品亚洲香蕉网站| 欧美sm重口味系列视频在线观看| 日韩视频免费| 久久午夜视频| 制服丝袜亚洲播放| 好看不卡的中文字幕| 欧美激情1区| 欧美黑人多人双交| 亚洲综合导航| 亚洲国产精品一区二区久| 欧美特黄视频| 亚洲制服av| 欧美国产激情| 欧美一区二区三区日韩| 一区二区亚洲| 国产精品久久久久久久一区探花| 久久er精品视频| 日韩视频在线你懂得| 久久免费午夜影院| 亚洲你懂的在线视频| 亚洲国产精品一区二区第一页 | 国产精品网站视频| 欧美成人激情视频| 欧美在线三级| 亚洲一卡久久| 亚洲国产三级在线| 亚洲精品免费一区二区三区| 国产伦精品一区二区三区视频孕妇| 欧美极品在线视频| 久久久国产视频91| 亚洲第一视频网站| 亚洲精品一区二| 极品日韩av| 国内精品模特av私拍在线观看| 欧美日韩第一区日日骚| 在线视频欧美日韩精品| 亚洲国产精品第一区二区| 猛男gaygay欧美视频| 久久久国产精品一区二区中文| 亚洲一区日本| 在线亚洲免费| 亚洲视频一二三| 一区二区三区日韩欧美精品| 亚洲区免费影片| 亚洲精品一区二区三区婷婷月| 好吊成人免视频| 国产亚洲欧洲| 韩国v欧美v日本v亚洲v| 国产一区二区三区免费观看 | 欧美激情精品久久久六区热门 | 亚洲色在线视频| 日韩一二在线观看| 一本一本久久a久久精品综合妖精| 亚洲国产精品悠悠久久琪琪| 欧美国产精品va在线观看| 欧美成人免费在线| 欧美激情视频一区二区三区在线播放 | 一区二区在线观看视频在线观看| 国产性猛交xxxx免费看久久| 国产一区二区三区自拍| 激情丁香综合| 亚洲精品久久| 宅男在线国产精品| 小处雏高清一区二区三区 | 狠狠久久亚洲欧美| 一区在线影院| 亚洲黄色视屏| 中文日韩电影网站| 亚洲欧美日韩中文播放| 久久精品欧美日韩精品| 开元免费观看欧美电视剧网站| 毛片基地黄久久久久久天堂| 欧美激情亚洲精品| 夜夜嗨一区二区三区| 午夜精品久久久久久久男人的天堂 | 亚洲性线免费观看视频成熟| 亚洲电影下载| 国产日韩1区| 欲色影视综合吧| 一区二区三区视频观看| 午夜一区二区三视频在线观看| 久久精品国产亚洲aⅴ| 欧美sm视频| 欧美国产大片| 亚洲视频一二三| 久久嫩草精品久久久精品| 欧美日韩情趣电影| 黄页网站一区| 亚洲一区二区三区乱码aⅴ蜜桃女| 久久岛国电影| 亚洲精品一区在线观看香蕉| 午夜精品视频网站| 亚洲欧美网站| 欧美激情亚洲另类| 国产一区三区三区| 一本久道久久综合狠狠爱| 久久亚洲春色中文字幕久久久| 亚洲精品乱码久久久久久蜜桃91| 欧美一区二区免费观在线| 欧美人牲a欧美精品| 极品中文字幕一区| 欧美一区二区久久久| 亚洲精品国产欧美| 久久频这里精品99香蕉|