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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品国产WWW456C0M| 亚洲AV无码久久精品狠狠爱浪潮| 久久99精品久久只有精品| 国产一级持黄大片99久久| 精品99久久aaa一级毛片| 99久久夜色精品国产网站| 久久se精品一区二区| 狠狠精品久久久无码中文字幕| 99精品国产在热久久| 欧美久久亚洲精品| 欧美精品一区二区精品久久| 久久亚洲精品国产亚洲老地址| 久久发布国产伦子伦精品| 无码国内精品久久人妻麻豆按摩| 精品国产乱码久久久久久郑州公司 | 国产成人无码精品久久久性色 | 7777久久亚洲中文字幕| 久久午夜无码鲁丝片秋霞| 久久成人18免费网站| 精品无码久久久久国产| 亚洲国产精品成人久久蜜臀 | 久久婷婷国产麻豆91天堂| 久久人人爽人人爽人人片AV不 | 久久99毛片免费观看不卡| 精品国产乱码久久久久久呢| 久久精品这里只有精99品| 国产精品久久久久久久| 国内精品久久久久影院一蜜桃| 狠狠色狠狠色综合久久| 久久久久免费精品国产| 久久人妻AV中文字幕| 久久久久亚洲AV无码观看| 久久91精品国产91久| 青春久久| 久久久久久久97| 77777亚洲午夜久久多人| 久久精品人妻中文系列| 亚洲综合伊人久久大杳蕉| 久久精品国产亚洲av日韩| 国产精品久久国产精麻豆99网站| 久久国产精品99精品国产|