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

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋

            題目地址:
                     http://acm.hdu.edu.cn/showproblem.php?pid=2147
            題目描述:
            kiki's game

            Time Limit: 
            5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others)
            Total Submission(s): 
            1806    Accepted Submission(s): 1055


            Problem Description
            Recently kiki has nothing to 
            do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top right corner(1,m). Each time one people can move the coin into the left, the underneath or the left-underneath blank space.The person who can't make a move will lose the game. kiki plays it with ZZ.The game always starts with kiki. If both play perfectly, who will win the game?
             

            Input
            Input contains multiple test cases. Each line contains two integer n, m (
            0<n,m<=2000). The input is terminated when n=0 and m=0.

             

            Output
            If kiki wins the game printf 
            "Wonderful!"else "What a pity!".
             

            Sample Input
            5 3
            5 4
            6 6
            0 0
             

            Sample Output
            What a pity
            !
            Wonderful
            !
            Wonderful
            !

            題目分析:
            一直WA , 分析也沒分析出來 , 百度了一下別人的解題報告后.............我承認....我被征服了.....................

            分析如下:
                     

            P點:就是P個石子的時候,對方拿可以贏(自己輸的)

            N點:就是N個石子的時候,自己拿可以贏

            現在關于P,N的求解有三個規則

            (1):最終態都是P

            (2):按照游戲規則,到達當前態的前態都是N的話,當前態是P

            (3):按照游戲規則,到達當前態的前態至少有一個P的話,當前態是N

             

            題意:

            在一個m*n的棋盤內,從(1,m)點出發,每次可以進行的移動是:左移一,下移一,左下移一。然后kiki每次先走,判斷kiki時候會贏(對方無路可走的時候)。

            我們可以把PN狀態的點描繪出來::

                                    

            這些點的描繪有一個程序::

            #include<iostream>
            using namespace std;
            bool map[2001][2001];//1 P 0 N;
            int main(){
                   int i,j,k;
                   map[1][1]=1;
                   for(i=2;i<=2000;i++)
                   {
                          if(map[i-1][1])
                                 map[i][1]=0;
                          else map[i][1]=1;
                          for(j=2;j<i;j++){
                                 if(!map[i][j-1]&&!map[i-1][j-1]&&!map[i-1][j])
                                        map[i][j]=1;
                                 else map[i][j]=0;
                          }
                          if(map[1][i-1])
                                 map[1][i]=0;
                          else map[1][i]=1;
                          for(j=2;j<i;j++){
                                 if(!map[j-1][i]&&!map[j-1][i-1]&&!map[j][i-1])
                                        map[j][i]=1;
                                 else map[j][i]=0;
                          }
                          if(!map[i][i-1]&&!map[i-1][i-1]&&!map[i-1][i])
                                 map[i][i]=1;
                          else map[i][i]=0;
                   }
                   int M,N;
                   for(i=1;i<=10;i++){
                          for(j=1;j<=10;j++)
                                 printf("%c ",map[i][j]?'P':'N');
                          printf("\n");
                   }
                   while(scanf("%d%d",&M,&N)&&M&&N){
                          if(map[M][N]) printf("What a pity!\n");
                          else printf("Wonderful!\n");
                   }
                   return 0;
            }


            具體代碼如下:
            #include <iostream>
            using namespace std;
            int main ()
            {
                
            int n,m;
                
            while ( cin >> n >> m , n + m )
                {
                      puts ( n
            %2 && m % 2 ? "What a pity!" : "Wonderful!"); 
                }
                
            return 0
            }

            Feedback

            # re: HDOJ 2147 HDU 2147 kiki's game ACM 2147 IN HDU   回復  更多評論   

            2011-08-01 17:27 by lsp
            服了

            # re: HDOJ 2147 HDU 2147 kiki's game ACM 2147 IN HDU   回復  更多評論   

            2011-08-01 17:29 by lsp
            看來以后拿到題不能隨便做啊!

            # re: HDOJ 2147 HDU 2147 kiki's game ACM 2147 IN HDU   回復  更多評論   

            2011-08-04 20:54 by 1111
            想到dp,總是超內存,卻沒想到這招,太強了!!!

            # re: HDOJ 2147 HDU 2147 kiki's game ACM 2147 IN HDU   回復  更多評論   

            2011-10-09 11:38 by tracy
            Onz, dp一直超內存,看來還是應該多開動腦筋啊

            # re: HDOJ 2147 HDU 2147 kiki's game ACM 2147 IN HDU   回復  更多評論   

            2011-10-10 10:36 by zufe_thibker
            果斷強大,五體投地
            99久久无色码中文字幕| 久久精品国产99国产精品| 亚洲国产另类久久久精品黑人| 久久午夜免费视频| 欧美亚洲国产精品久久蜜芽| 一本一道久久a久久精品综合 | 久久无码一区二区三区少妇 | 国产A级毛片久久久精品毛片| 久久久久亚洲av无码专区导航| 国产精品美女久久久免费| 香蕉久久av一区二区三区| 久久99精品久久久久久野外| 日韩精品久久久久久久电影蜜臀| 久久久久亚洲AV无码专区桃色| 久久精品国产精品亚洲毛片| 亚洲va久久久久| 久久人人超碰精品CAOPOREN| 久久精品中文闷骚内射| 国产成人久久精品一区二区三区| 久久精品国产WWW456C0M| 久久国产精品久久国产精品| 久久综合香蕉国产蜜臀AV| 久久久国产精华液| 久久久精品久久久久影院| 久久综合色区| 久久久久久极精品久久久| 久久久国产精品| 久久亚洲av无码精品浪潮| 狠狠色丁香婷婷综合久久来来去| 国产精品毛片久久久久久久| 国产精品久久久久久搜索| 99999久久久久久亚洲| 精品乱码久久久久久久| 2020久久精品国产免费| 久久99精品国产麻豆宅宅| 热久久国产精品| 久久综合伊人77777麻豆| 国产精品久久久久久久久软件| 欧美精品九九99久久在观看| 亚洲中文久久精品无码| 久久久精品人妻一区二区三区蜜桃|