• <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
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 216643
            • 排名 - 117

            最新評論

            閱讀排行榜

            評論排行榜

            Cake Cutting
            Time Limit:1000MS? Memory Limit:65536K
            Total Submit:528 Accepted:228

            Description

            You are given a rectangular cake of integral dimensions w × h. Your goal is to divide this cake into m rectangular pieces of integral dimensions such that the area of the largest piece is minimal. Each cut must be a straight line parallel to one of the sides of the original cake and must divide a piece of cake into two new pieces of positive area. Note that since a cut divides only a single piece, exactly m ? 1 cuts are needed.

            If w = 4, h = 4, and m = 4, then the following cuts minimize the area of the largest piece:

            However, if w = 4, h = 4, and m = 3, then the following cuts are optimal:

            Input

            The input test file will contain multiple test cases, each of which consists of three integers w, h, m separated by a single space, with 1 ≤ w, h, m ≤ 20 and mwh. The end-of-file is marked by a test case with w = h = m = 0 and should not be processed.

            Output

            For each test case, write a single line with a positive integer indicating the area of the largest piece.

            Sample Input

            4 4 4
            4 4 3
            0 0 0

            Sample Output

            4
            6

            Source
            Stanford Local 2004

            用了記憶化搜索, 900多ms才過掉, rp好啊..

            #include? < iostream >
            using ? namespace ?std;

            int ?f[ 21 ][ 21 ][ 21 ];

            int ?lookup( int ?w,? int ?h,? int ?k)
            {
            ????
            if ?(f[w][h][k]? > ? 0 )? return ?f[w][h][k];
            ????
            if ?(k? == ? 1 )
            ????
            {
            ????????f[w][h][k]?
            = ?w? * ?h;
            ????????
            return ?f[w][h][k];
            ????}

            ????
            int ?i,?j;
            ????
            int ?max1? = ? 2000000000 ,?max2? = ? 2000000000 ;
            ????
            int ?t;

            ????
            // t?=?0;
            ???? for ?(i = 1 ;?i < w;?i ++ )
            ????
            {
            ????????
            for ?(j = 1 ;?j < k;?j ++ )
            ????????
            {
            ????????????
            if ?(i * h? >= ?j? && ?(w - i) * h? >= ?k - j)
            ????????????
            {
            ????????????????t?
            = ?lookup(i,?h,?j)? > ?lookup(w - i,?h,?k - j)? ? ?lookup(i,?h,?j)?:?lookup(w - i,?h,?k - j);
            ????????????????
            if ?(max1? > ?t)
            ????????????????????max1?
            = ?t;
            ????????????}

            ????????}

            ????}


            ????
            // t?=?0;
            ???? for ?(i = 1 ;?i < h;?i ++ )
            ????
            {
            ????????
            for ?(j = 1 ;?j < k;?j ++ )
            ????????
            {
            ????????????
            if ?(w * i? >= ?j? && ?w * (h - i)? >= ?k - j)
            ????????????
            {
            ????????????????t?
            = ?lookup(w,?i,?j)? > ?lookup(w,?h - i,?k - j)? ? ?lookup(w,?i,?j)?:?lookup(w,?h - i,?k - j);
            ????????????????
            if ?(max2? > ?t)
            ????????????????????max2?
            = ?t;
            ????????????}

            ????????}

            ????}


            ????f[w][h][k]?
            = ?max1? < ?max2? ? ?max1?:?max2;
            ????
            return ?f[w][h][k];
            }


            int ?g( int ?w,? int ?h,? int ?k)
            {
            ????memset(f,?
            0 ,? sizeof (f));
            ????
            return ?lookup(w,?h,?k);
            }


            int ?main()
            {
            ????
            int ?w,?h,?m;

            ????
            while ?(scanf( " %d%d%d " ,? & w,? & h,? & m)? != ?EOF)
            ????
            {
            ????????
            if ?(w? == ? 0 ? && ?h? == ? 0 ? && ?m? == ? 0 )? break ;
            ????????printf(
            " %d\n " ,?g(w,?h,?m));
            ????}

            ????
            return ? 0 ;
            }
            posted on 2006-09-07 23:43 閱讀(573) 評論(0)  編輯 收藏 引用 所屬分類: ACM題目
            久久国产精品99国产精| 很黄很污的网站久久mimi色| 久久精品无码一区二区三区免费| 国内精品人妻无码久久久影院 | 一极黄色视频久久网站| 久久九九免费高清视频| 精品无码久久久久久国产| 久久中文字幕无码专区| 久久精品国产99国产精品亚洲| 亚洲中文字幕久久精品无码喷水| 亚洲国产精品综合久久一线| 少妇内射兰兰久久| 国产成人精品久久一区二区三区av| 国产精品久久免费| 久久久精品日本一区二区三区| 精品久久久久久中文字幕大豆网| 久久天天躁狠狠躁夜夜网站| 国产午夜精品理论片久久| 久久伊人精品一区二区三区| 精品久久久久久久久中文字幕| 久久综合色老色| 久久精品一区二区国产| 久久久久久久久66精品片| 久久综合中文字幕| 国产精品无码久久久久久| 久久精品综合网| 久久久亚洲欧洲日产国码是AV| 国产精品久久永久免费| 国产A级毛片久久久精品毛片| 久久久久久毛片免费看| 国产99久久久国产精品小说| 久久久久亚洲精品天堂久久久久久 | 久久精品国产一区二区三区| 久久精品人成免费| 色悠久久久久久久综合网| 国产成人香蕉久久久久| 久久久久噜噜噜亚洲熟女综合| 久久久无码精品亚洲日韩蜜臀浪潮| 国产香蕉久久精品综合网| 久久这里有精品| 18岁日韩内射颜射午夜久久成人|