• <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 閱讀(203) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久人人超碰精品CAOPOREN| 国产精品欧美久久久久无广告| 日日狠狠久久偷偷色综合免费| 色婷婷噜噜久久国产精品12p| 少妇人妻综合久久中文字幕| 国产91色综合久久免费分享| 久久国产成人午夜AV影院| 久久天天躁夜夜躁狠狠| 国产美女久久精品香蕉69| 欧美色综合久久久久久| 久久777国产线看观看精品| 久久精品国产乱子伦| 国产精品成人久久久久三级午夜电影 | 久久久亚洲欧洲日产国码二区 | 久久综合久久美利坚合众国| 精品乱码久久久久久久| 久久天天婷婷五月俺也去 | 精品国产91久久久久久久a| 亚洲伊人久久大香线蕉综合图片 | 亚洲国产精品成人久久| 久久综合五月丁香久久激情| 婷婷久久久亚洲欧洲日产国码AV| 色综合久久久久久久久五月| 99久久免费国产精品热| 国产精品一久久香蕉国产线看| 久久99中文字幕久久| 午夜精品久久久内射近拍高清 | 久久久精品人妻无码专区不卡| 狠狠色丁香久久婷婷综合五月| 97久久精品人人做人人爽| 亚洲国产成人久久综合碰碰动漫3d | 精品无码久久久久国产动漫3d | 久久精品国产久精国产果冻传媒| 国产成人99久久亚洲综合精品| 亚洲AV无码久久| 亚洲欧洲日产国码无码久久99| 久久一区二区免费播放| 久久九九久精品国产免费直播| 狠狠人妻久久久久久综合蜜桃| 久久精品国产欧美日韩| 久久涩综合|