• <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>

            O(1) 的小樂

            Job Hunting

            公告

            記錄我的生活和工作。。。
            <2010年10月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            統計

            • 隨筆 - 182
            • 文章 - 1
            • 評論 - 41
            • 引用 - 0

            留言簿(10)

            隨筆分類(70)

            隨筆檔案(182)

            文章檔案(1)

            如影隨形

            搜索

            •  

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            USACO 2.3 Money Systems

            /*
            ID: lvxiaol3
            LANG: C++
            TASK: money
            */
            #include <iostream>
            #include <vector>
            #include <fstream>
            #include <algorithm>
            #include <string>
            #include <set>
            #include <cstdio>
            using namespace std;

             

            int main()
            {
                ifstream fin("money.in");
                ofstream fout("money.out");
                int V, N;
                fin>>V>>N;
                vector<int> Coin(V);
                for(int i=0; i<V; i++) fin>>Coin[i];
                sort(Coin.begin(),Coin.end());

                long long  dp[2][10005];
                for(int i=0;i<V; i++) dp[i%2][0]=1LL;
                int temp=Coin[0];
                while(temp<=N) {dp[0][temp]=1;temp+=Coin[0];}

                for(int i=1; i<V;i++)
                {
                    for(int j=1;j<=N;j++)
                    {
                        int m=j;
                        dp[i%2][j]=0;
                        while(m>=0)
                        {
                            dp[i%2][j]+=dp[(i-1)%2][m];
                            m-=Coin[i];
                        }
                    }
                }
                fout<<dp[(V-1)%2][N]<<endl;


                return 0;
            }
            /*
            3 10
            1 2 5

            1 1 1 1 1 1 1 1 1 1 1
            1 1 2 2 3 3 4 4 5 5 6
            1 1 2 2 3 4 5 6 7 8 10
            10

            Process returned 0 (0x0)   execution time : 0.027 s
            Press any key to continue.

            */
            // dp[k][n] the previous k kind of coins consist of n
            // dp[k][n]= /sum{dp[k-1][n-p*v[k]] } p>=0

             

            下面這一步的dp優化贊!利用DP狀態改變的順序來優化dp的復雜度
            /*
            for(i=0; i<v; i++) {
                    fscanf(fin, "%d", &c);

                    for(j=c; j<=n; j++)
                        nway[j] += nway[j-c];
                }
            */

            posted on 2011-10-19 22:14 Sosi 閱讀(121) 評論(0)  編輯 收藏 引用

            統計系統
            国产韩国精品一区二区三区久久| 99精品久久精品一区二区| 久久成人影院精品777| 久久久久久九九99精品| 91视频国产91久久久| 国产精品成人99久久久久| 亚洲精品乱码久久久久久蜜桃| 久久夜色撩人精品国产| 午夜久久久久久禁播电影| 69久久精品无码一区二区| 久久天天躁狠狠躁夜夜2020老熟妇 | 午夜天堂av天堂久久久| 久久夜色精品国产噜噜亚洲AV| 72种姿势欧美久久久久大黄蕉| 欧美一级久久久久久久大片| 亚洲精品美女久久久久99| 国产精品免费久久久久电影网| 亚洲欧美日韩精品久久亚洲区 | 国产成人精品久久| 粉嫩小泬无遮挡久久久久久| 99久久人人爽亚洲精品美女| 久久亚洲sm情趣捆绑调教| 精品亚洲综合久久中文字幕| 狠狠色丁香久久婷婷综合图片 | 久久精品国产亚洲精品| 亚洲AV无码久久精品狠狠爱浪潮| 亚洲精品国产成人99久久| 亚洲va中文字幕无码久久不卡| 女人香蕉久久**毛片精品| 人妻无码中文久久久久专区| 日韩va亚洲va欧美va久久| 国产成人久久久精品二区三区| 亚洲精品美女久久777777| 区亚洲欧美一级久久精品亚洲精品成人网久久久久| 狠狠色综合网站久久久久久久高清 | 偷偷做久久久久网站| 久久国产精品国产自线拍免费| 东方aⅴ免费观看久久av| 久久久久久久亚洲精品| 国产精品综合久久第一页| AAA级久久久精品无码片|