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

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 閱讀(491) 評論(0)  編輯 收藏 引用 所屬分類: 動態規劃
<2012年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用鏈接

留言簿(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>
            亚洲午夜av在线| 亚洲欧美日韩国产综合精品二区| 久久九九精品99国产精品| 99re66热这里只有精品3直播| 亚洲国产精品第一区二区三区 | 欧美午夜视频在线观看| 欧美视频国产精品| 国产午夜亚洲精品理论片色戒| 国产日本欧美一区二区| 在线观看av一区| 最新亚洲视频| 亚洲制服丝袜在线| 玖玖玖国产精品| 亚洲精品视频在线| 香蕉视频成人在线观看| 久久黄色影院| 欧美日本韩国一区| 国产日韩av高清| 亚洲人www| 午夜视频久久久| 欧美不卡三区| 国内成人自拍视频| 99精品福利视频| 久久精品成人| 亚洲全部视频| 午夜在线视频观看日韩17c| 久久资源在线| 国产精品视频免费观看www| 在线观看一区| 欧美一区二区福利在线| 欧美激情精品久久久久久| av成人免费| 免费观看不卡av| 国产视频久久| 中文精品视频一区二区在线观看| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲天堂av图片| 欧美精品v国产精品v日韩精品 | 欧美日韩网址| 亚洲国产欧美在线人成| 欧美主播一区二区三区| 亚洲天堂成人在线观看| 欧美肥婆在线| 亚洲第一在线| 久久久噜噜噜久久中文字免| 一区二区三区视频在线看| 农村妇女精品| 在线观看日韩av电影| 久久久国产精品一区二区中文| 在线视频精品| 欧美性感一类影片在线播放| 亚洲免费av片| 亚洲国产色一区| 美女福利精品视频| 亚洲国产精品嫩草影院| 欧美在线www| 国产精品成人va在线观看| 久久久精品一品道一区| 亚洲国产精品久久久久| 久久久精品一区二区三区| 国产精品乱码人人做人人爱| 亚洲天堂免费观看| 国产精品一区二区三区免费观看| 久久激情视频免费观看| 精品成人在线视频| 亚洲一区二区三区在线视频| 中日韩高清电影网| 欧美成人三级在线| 久久久国产精品一区| 尹人成人综合网| 欧美在线播放高清精品| 亚洲激情第一页| 一区二区电影免费在线观看| 亚洲美女一区| 国产精品一区一区| 老色批av在线精品| 欧美亚洲网站| 亚洲黄色片网站| 久久一区二区三区av| 国产一区二区三区直播精品电影| 欧美一区二区三区久久精品茉莉花| 亚洲免费视频网站| 国产日韩欧美视频在线| 久久久久国产精品www| 欧美午夜片欧美片在线观看| 亚洲欧美韩国| 欧美影院久久久| 激情91久久| 99视频精品在线| 国产一区999| 欧美高清视频在线播放| 国产精品高潮呻吟视频 | 日韩视频一区二区在线观看| 一本色道久久加勒比精品| 国产一区二区三区四区老人| 亚洲国产成人tv| 国产精品免费在线| 免费看成人av| 国产精品人成在线观看免费| 久久亚洲综合色| 欧美日韩国产小视频在线观看| 欧美一区1区三区3区公司| 久久天堂国产精品| 午夜视频在线观看一区| 欧美亚洲免费| 欧美精品系列| 久久在线播放| 国产精品嫩草久久久久| 久久精品国产综合精品| 欧美日韩中文字幕在线| 性欧美精品高清| 玖玖玖国产精品| 亚洲永久字幕| 另类专区欧美制服同性| 亚洲一区二区免费看| 久久久999| 午夜精品福利一区二区三区av | 久久久av网站| 欧美一激情一区二区三区| 欧美激情亚洲精品| 美女999久久久精品视频| 国产精品成人久久久久| 免费日韩视频| 国内精品视频在线观看| 亚洲在线免费观看| 亚洲综合精品四区| 亚洲男人av电影| 亚洲先锋成人| 欧美激情精品久久久久久免费印度| 久久久久这里只有精品| 国产精品羞羞答答xxdd| 日韩手机在线导航| 亚洲精品乱码久久久久久蜜桃91| 久久av一区| 久久精品av麻豆的观看方式| 国产九九精品| 亚洲综合电影| 欧美在线不卡| 国产精品一二三四区| 日韩一级裸体免费视频| 一区二区三区成人| 欧美精品在线一区二区| 亚洲第一精品夜夜躁人人躁| 怡红院精品视频| 欧美在线视频一区二区三区| 久久久综合网站| 依依成人综合视频| 久久男女视频| 欧美国产日韩一区二区| 亚洲国产一区二区三区高清 | 久久国产视频网| 国产一区999| 免费久久久一本精品久久区| 亚洲第一中文字幕| 99热这里只有成人精品国产| 欧美手机在线视频| 亚洲一区日韩在线| 久久久久久夜| 亚洲激情另类| 国产精品成人一区| 欧美专区在线观看一区| 久久久久欧美精品| 亚洲国产精品一区制服丝袜| 欧美 日韩 国产在线| 亚洲乱码精品一二三四区日韩在线| 一区二区三区久久网| 国产精品一区二区久久| 欧美一区激情| 久久精品男女| 亚洲综合色在线| 国产欧美精品日韩精品| 久久久91精品国产| 亚洲人永久免费| 亚洲性人人天天夜夜摸| 国产视频在线观看一区二区三区| 欧美中文在线免费| 欧美一级免费视频| 欧美福利电影在线观看| 国产一区二区三区久久悠悠色av | 一区二区日本视频| 国产精品日本一区二区 | 影音国产精品| 久久久久久久久蜜桃| 欧美波霸影院| 欧美视频在线免费看| 一区在线播放| 红桃视频一区| 先锋影音国产一区| 一本久久综合亚洲鲁鲁| 亚洲美女中出| 一区二区三区波多野结衣在线观看| 国产精品v欧美精品v日本精品动漫| 亚洲欧美国产不卡| 永久免费精品影视网站| 欧美激情一级片一区二区| 亚洲第一福利在线观看| 永久久久久久| 亚洲伊人观看| 男男成人高潮片免费网站| 欧美一区二区三区日韩|