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

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 閱讀(500) 評論(0)  編輯 收藏 引用 所屬分類: 動態(tài)規(guī)劃
<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用鏈接

留言簿(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>
            美女视频黄 久久| 久久躁狠狠躁夜夜爽| 性欧美xxxx视频在线观看| 裸体歌舞表演一区二区| 亚洲欧美另类在线观看| 欧美日韩成人激情| 亚洲国语精品自产拍在线观看| 欧美一区观看| 亚洲欧美中文在线视频| 国产精品热久久久久夜色精品三区 | 亚洲天堂av在线免费| 亚洲电影下载| 小黄鸭精品aⅴ导航网站入口| 欧美香蕉大胸在线视频观看| 中日韩美女免费视频网址在线观看 | 久久久国产精品一区二区中文| 亚洲视频二区| 国产精品久久久免费| 午夜国产精品视频| 亚洲欧美日韩在线观看a三区| 国产目拍亚洲精品99久久精品 | 亚洲精品一区二区网址| 欧美日韩1区2区| 亚洲欧美综合一区| 久久精品91久久香蕉加勒比| 亚洲大片在线| 91久久在线观看| 欧美午夜精彩| 久久久999国产| 老司机凹凸av亚洲导航| 夜夜嗨av一区二区三区中文字幕| 夜夜嗨av色一区二区不卡| 国产精品青草久久久久福利99| 欧美一区二区三区日韩| 久久精品在线| 99国产欧美久久久精品| 亚洲一区二区三区四区视频| 狠狠综合久久av一区二区小说| 欧美风情在线观看| 国产精品成av人在线视午夜片| 欧美一区二区高清| 午夜精品在线看| 日韩一级在线| 亚洲欧美bt| 亚洲美女91| 亚洲人成网站色ww在线| 日韩亚洲欧美在线观看| 亚洲淫片在线视频| 亚洲二区在线| 在线综合欧美| 黄网站免费久久| 一本综合精品| 亚洲高清资源| 亚洲一区精彩视频| 亚洲人体一区| 欧美一区二区在线视频| 日韩亚洲欧美中文三级| 久久久久久999| 正在播放亚洲一区| 欧美在线亚洲| 亚洲尤物在线视频观看| 久久综合久久综合久久| 欧美一站二站| 欧美无砖砖区免费| 欧美激情一区二区| 国产在线视频欧美一区二区三区| a91a精品视频在线观看| 亚洲精品美女在线| 久久久久久夜精品精品免费| 欧美一区二区三区四区高清| 久久综合色一综合色88| 久久精品99国产精品| 国产精品黄视频| 99pao成人国产永久免费视频| 亚洲黄页一区| 久久综合色综合88| 美女图片一区二区| 韩国一区二区三区在线观看| 亚洲欧美国产高清va在线播| 一区二区免费在线视频| 久久伊人一区二区| 久久精品一区二区国产| 国产情人节一区| 夜夜嗨av一区二区三区| 亚洲特级毛片| 欧美日韩一区二区在线视频 | 午夜精品久久久久久久| 亚洲一级黄色片| 欧美女激情福利| 亚洲黄网站黄| 在线一区免费观看| 欧美午夜精品| 亚洲欧美美女| 久久九九免费| 亚洲二区在线| 欧美日韩国产精品成人| 亚洲精品一区二区三区蜜桃久| 一本色道久久综合亚洲精品小说| 欧美精品在线网站| av成人免费| 久久riav二区三区| 黄色亚洲精品| 欧美91大片| 91久久综合| 亚洲自拍偷拍色片视频| 国产精品一区二区在线| 欧美在线视频一区二区| 欧美国产精品日韩| 亚洲激情偷拍| 欧美日韩免费观看一区| 中文无字幕一区二区三区| 国产精品久久一区主播| 久久久久国产精品一区二区| 一区二区三区不卡视频在线观看| 亚洲欧美偷拍卡通变态| 亚洲精品一二三区| 在线免费一区三区| 国产综合色在线视频区| 国产主播一区二区三区| 国产欧美亚洲一区| 欧美日韩直播| 国产精品视频一| 国产精品久久久一区二区三区| 欧美日本免费| 国产日韩精品一区二区三区| 国产精品一区二区久久| 狠狠色丁香婷婷综合影院| 国产一区二区电影在线观看| 狠狠久久婷婷| 99综合在线| 午夜亚洲福利在线老司机| 欧美成人精品不卡视频在线观看| 亚洲黄色精品| 亚洲最新合集| 久久精品国产一区二区三区| 欧美成人dvd在线视频| 国产精品夜夜夜| 亚洲激情在线观看视频免费| 久久国产毛片| 日韩午夜高潮| 国产精品久久久久9999高清| 久久久久久久久久久成人| 欧美成人免费在线| 欧美在线在线| 欧美日韩一区二区欧美激情| 久久精品一区二区三区中文字幕 | 影音先锋亚洲电影| 99国产麻豆精品| 亚洲精品乱码久久久久久| 欧美色中文字幕| 亚洲视频一区二区| 欧美第一黄网免费网站| 亚洲国产精品一区二区三区| 狂野欧美一区| 99xxxx成人网| 日韩网站在线| 欧美性事在线| 久久精品视频在线| 久久综合伊人77777蜜臀| 在线免费一区三区| 亚洲区欧美区| 欧美性一区二区| 久久成年人视频| 毛片一区二区| 亚洲综合首页| 久久精品一二三| 亚洲欧美日韩区| 久久精品国产99| 日韩一级精品视频在线观看| 先锋影音国产一区| 亚洲日本黄色| 亚洲性人人天天夜夜摸| 在线观看亚洲一区| 亚洲性图久久| 亚洲色图自拍| 欧美国产欧美亚洲国产日韩mv天天看完整 | 国产日韩精品一区| 中国av一区| 久久国产主播精品| 亚洲裸体视频| 激情久久久久久久| 欧美日韩中文| 欧美日韩国产成人在线免费 | 亚洲欧美日韩中文播放| 亚洲高清视频一区二区| 欧美资源在线| 亚洲午夜一二三区视频| 国产精品美女诱惑| 一区二区三区.www| 久久亚洲影音av资源网| 欧美日韩在线一区| 亚洲精品国产精品国自产在线 | 欧美区日韩区| 亚洲国产一区视频| 亚洲狠狠婷婷| 欧美日韩精选| 午夜久久黄色| 亚洲国产三级在线| 亚洲一区三区电影在线观看| 国产精自产拍久久久久久|