• <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>
            隨筆 - 87  文章 - 279  trackbacks - 0
            <2007年4月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 216559
            • 排名 - 117

            最新評論

            閱讀排行榜

            評論排行榜

            PKU 3093 Margaritas on the River Walk
                    先對輸入的數組排序,然后類似于01對a[i]做決策,核心代碼加了注釋:
                     for (i=1; i<=n; i++) {
                             for (j=1; j<=maxsum; j++) {
                                    if (j >= sum[i]) d[i][j] = 1; //j比sum[i]大,肯定這時候d[i][j]=1;
                                    else {
                                            d[i][j] = d[i-1][j];//不考慮a[i]
                                            if (j-a[i]>=0) {//考慮a[i]
                                                     if (d[i-1][j-a[i]] > 0) d[i][j] += d[i-1][j-a[i]];//把a[i]加進以前的選擇里面
                                                     else d[i][j]++;//a[i]單獨作為一個選擇(這里需要先對a[i]排序,消除后效性)
                                           }
                                    }
                             }
                     }

            PKU 1037 A decorative fence
                    先dp算出以i為起點的序列的個數,再組合數學
                    td[n][i]和tu[n][i]分別表示個數為n,以i開始的上升和下降的序列個數
                    易知:
                    td[n][1] = 0;
                    td[n][i] = sigma(tu[n-1][j], j從1..i-1)  = td[n][i-1] + tu[n-1][i-1] ;
                    tu[n][i]  = td[n][n+i-1];

            PKU 2677 Tour
                    雙調歐幾里德旅行商問題(明顯階段dp)
                    動態規劃方程 :d[i+1][i] = mint(d[i+1][i], d[i][j]+g[j][i+1]); 
                                                  d[i+1][j] = mint(d[i+1][j], d[i][j]+g[i][i+1]);
                                                   0<=j<i   

            PKU 2288 Islands and Bridges
                    集合DP
                    狀態表示: d[i][j][k] (i為13為二進制表示點的狀態, j為當前節點, k為到達j的前驅節點)

            posted on 2007-04-20 18:10 閱讀(2119) 評論(5)  編輯 收藏 引用 所屬分類: 算法&ACM

            FeedBack:
            # re: 對一些DP題目的小結 2007-04-22 08:56 byron
            豪大牛,問一下,這是一些題目嗎????  回復  更多評論
              
            # re: 對一些DP題目的小結 2007-04-24 00:52 
            @byron
            是pku上的題目,我菜菜啊。。。  回復  更多評論
              
            # re: 對一些DP題目的小結 2007-04-26 18:59 oyjpart
            呵呵 就聊上了啊 :)  回復  更多評論
              
            # re: 對一些DP題目的小結 2007-06-30 22:55 姜雨生
            Margaritas on the River Walk
            Time Limit:1000MS Memory Limit:65536K
            Total Submit:309 Accepted:132

            Description


            One of the more popular activities in San Antonio is to enjoy margaritas in the park along the river know as the River Walk. Margaritas may be purchased at many establishments along the River Walk from fancy hotels to Joe’s Taco and Margarita stand. (The problem is not to find out how Joe got a liquor license. That involves Texas politics and thus is much too difficult for an ACM contest problem.) The prices of the margaritas vary depending on the amount and quality of the ingredients and the ambience of the establishment. You have allocated a certain amount of money to sampling different margaritas.

            Given the price of a single margarita (including applicable taxes and gratuities) at each of the various establishments and the amount allocated to sampling the margaritas, find out how many different maximal combinations, choosing at most one margarita from each establishment, you can purchase. A valid combination must have a total price no more than the allocated amount and the unused amount (allocated amount – total price) must be less than the price of any establishment that was not selected. (Otherwise you could add that establishment to the combination.)

            For example, suppose you have $25 to spend and the prices (whole dollar amounts) are:

            Vendor A B C D H J
            Price 8 9 8 7 16 5

            Then possible combinations (with their prices) are:

            ABC(25), ABD(24), ABJ(22), ACD(23), ACJ(21), ADJ( 20), AH(24), BCD(24), BCJ(22), BDJ(21), BH(25), CDJ(20), CH(24), DH(23) and HJ(21).

            Thus the total number of combinations is 15.


            Input


            The input begins with a line containing an integer value specifying the number of datasets that follow, N (1 ≤ N ≤ 1000). Each dataset starts with a line containing two integer values V and D representing the number of vendors (1 ≤ V ≤ 30) and the dollar amount to spend (1 ≤ D ≤ 1000) respectively. The two values will be separated by one or more spaces. The remainder of each dataset consists of one or more lines, each containing one or more integer values representing the cost of a margarita for each vendor. There will be a total of V cost values specified. The cost of a margarita is always at least one (1). Input values will be chosen so the result will fit in a 32 bit unsigned integer.


            Output


            For each problem instance, the output will be a single line containing the dataset number, followed by a single space and then the number of combinations for that problem instance.


            Sample Input


            2
            6 25
            8 9 8 7 16 5
            30 250
            1 2 3 4 5 6 7 8 9 10 11
            12 13 14 15 16 17 18 19 20
            21 22 23 24 25 26 27 28 29 30

            Sample Output


            1 15
            2 16509438

            Hint


            Note: Some solution methods for this problem may be exponential in the number of vendors. For these methods, the time limit may be exceeded on problem instances with a large number of vendors such as the second example below.


            Source
            Greater New York 2006
              回復  更多評論
              
            # re: 對一些DP題目的小結 2007-06-30 22:59 姜雨生
            應該可以更加優化  回復  更多評論
              
            久久精品国产色蜜蜜麻豆| 狠色狠色狠狠色综合久久| 一本久久综合亚洲鲁鲁五月天| 伊人久久大香线蕉综合5g| 久久久久人妻一区二区三区vr| 99久久www免费人成精品 | 久久99精品久久久久久噜噜 | 久久午夜综合久久| 亚洲AV无码久久精品蜜桃| 国产免费久久精品丫丫| 2021最新久久久视精品爱| 日本一区精品久久久久影院| 一本久久a久久精品综合香蕉| 久久夜色精品国产亚洲| 看久久久久久a级毛片| 性做久久久久久久久| 久久精品国产精品亚洲精品| 亚洲中文字幕久久精品无码喷水 | 国产午夜福利精品久久2021| 性高朝久久久久久久久久| 亚洲欧美精品伊人久久| 久久男人Av资源网站无码软件| 久久频这里精品99香蕉久| 国产精品日韩深夜福利久久| 国产一久久香蕉国产线看观看| 亚洲国产另类久久久精品小说 | 久久午夜伦鲁片免费无码| 性做久久久久久久久| 久久久精品人妻无码专区不卡| 国内精品久久久久| 精品久久久久久成人AV| 99精品久久精品一区二区| 婷婷五月深深久久精品| 久久久女人与动物群交毛片| 一本色道久久HEZYO无码| 久久久久久久精品妇女99| 国产成人精品久久| 久久久久亚洲av无码专区| 国内精品久久国产大陆| 四虎国产精品免费久久久| 久久精品无码一区二区三区免费|