• <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>
            posts - 195,  comments - 30,  trackbacks - 0
            #include <iostream>
            using namespace std;

            int path[6][6];
            int row,col,v,h;

            bool OK(int i,int j)
            {
            if(i>=0 && i<row && j>=0 && j<col)
               
            return true;
            return false;
            }

            void DFS(int i,int j,int & counts)
            {
            if(path[i][j]==1)
            {
               
            if(i==&& j==h)
                counts
            ++;
               
            return ;
            }
            path[i][j]
            =1;
            if(OK(i-2,j-1))
               DFS(i
            -2,j-1,counts);
            if(OK(i-2,j+1))
               DFS(i
            -2,j+1,counts);
            if(OK(i-1,j-2))
               DFS(i
            -1,j-2,counts);
            if(OK(i+1,j-2))
               DFS(i
            +1,j-2,counts);
            if(OK(i-1,j+2))
               DFS(i
            -1,j+2,counts);
            if(OK(i+1,j+2))
               DFS(i
            +1,j+2,counts);
            if(OK(i+2,j-1))
               DFS(i
            +2,j-1,counts);
            if(OK(i+2,j+1))
               DFS(i
            +2,j+1,counts);
            path[i][j]
            =0;
            }
            int main()
            {
                freopen(
            "s.txt","r",stdin);
              freopen(
            "key.txt","w",stdout);
            while(cin>>row>>col>>v>>h)
            {
               memset(path,
            0,sizeof(path));
               
            int counts=0;
               DFS(v,h,counts);
               cout
            <<counts<<endl;
            }
            return 0;
            }

            On a chess board sizes of m*n(1<=m<=5,1<=n<=5),given a start position,work out the amount of all the different paths through which the horse could return to the start position.(The position that the horse passed in one path must be different.The horse jumps in a way like "日")

            Input

            The input consists of several test cases.The size of the chess board m,n(row,column),and the start position v,h(vertical , horizontal) ,separated by a space.The left-up point is (0,0)

            Output

            the amount of the paths in a single line

            Sample Input

            5 4 3 1
            

            Sample output

            4596
            解析:
            馬走日,八個方向,
            不允許某條路徑上重復。
            if(path[i][j]==1)
            {
               if(i==v && j==h)
                counts++;
            //重復的如果是出發點,返回值
               return ;//無論怎樣,只要重復就返回
            }
            posted on 2009-06-28 18:11 luis 閱讀(208) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品久久久久aaaa| 久久国产免费直播| 伊人久久大香线焦综合四虎| 国产精品久久久久jk制服| 久久99国产精品久久99果冻传媒| 色综合色天天久久婷婷基地| 亚洲国产精品一区二区三区久久| 久久人人爽人人爽人人片av麻烦 | 久久精品无码午夜福利理论片| 久久综合给合久久狠狠狠97色69| 久久久青草久久久青草| 亚洲精品国精品久久99热| 精品免费tv久久久久久久| 久久久精品视频免费观看| 久久精品国产精品亚洲精品| 久久精品一区二区三区不卡| 久久综合色老色| 免费精品99久久国产综合精品| 麻豆av久久av盛宴av| 丰满少妇人妻久久久久久4| 亚洲国产精品一区二区久久hs| 精品乱码久久久久久夜夜嗨| 99久久婷婷国产综合亚洲| 中文字幕久久精品| 久久久久国产一级毛片高清板| 久久精品国产网红主播| 久久AV高潮AV无码AV| 精品久久久无码中文字幕| 国产产无码乱码精品久久鸭| 精品一二三区久久aaa片| 欧美色综合久久久久久| 久久精品无码一区二区三区日韩| 国产精品对白刺激久久久| 国产成人久久AV免费| 久久亚洲AV成人出白浆无码国产 | 国产成人久久精品麻豆一区| 国产情侣久久久久aⅴ免费| 久久亚洲美女精品国产精品| 久久久久久无码Av成人影院| 久久久亚洲欧洲日产国码二区| 久久无码人妻一区二区三区午夜 |