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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久国产免费观看精品| 色8久久人人97超碰香蕉987| 色综合久久综精品| 久久国产精品波多野结衣AV | 国产精品亚洲综合久久| 一本一本久久A久久综合精品| 久久久久高潮综合影院| 99久久精品费精品国产一区二区| 国产福利电影一区二区三区久久久久成人精品综合 | 久久国产精品偷99| 久久久国产亚洲精品| 狠狠色丁香婷综合久久| 国产成人无码精品久久久性色| 91精品国产91热久久久久福利 | 国产农村妇女毛片精品久久| 午夜精品久久久久久久| 久久亚洲高清综合| 久久综合中文字幕| 狠狠88综合久久久久综合网| 手机看片久久高清国产日韩| 久久不射电影网| 69久久夜色精品国产69| 久久久噜噜噜www成人网| 精品伊人久久大线蕉色首页| 久久精品免费大片国产大片| 日韩亚洲欧美久久久www综合网 | 久久精品成人欧美大片| 久久精品国产99久久久| 麻豆成人久久精品二区三区免费 | 久久精品麻豆日日躁夜夜躁| 久久无码AV中文出轨人妻| 国内精品久久久久久久影视麻豆 | 久久久久国产一区二区| 精品久久久久久无码中文野结衣| 久久精品国产一区二区三区日韩| 精品国产乱码久久久久久呢 | 人妻无码久久精品| 久久久久99精品成人片牛牛影视| 国内精品久久久久久久亚洲| 国产成人久久精品麻豆一区| 久久av高潮av无码av喷吹|