• <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)  編輯 收藏 引用 所屬分類: 搜索
            <2011年5月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            一个色综合久久| 欧美丰满熟妇BBB久久久| 狠狠色丁香婷综合久久| 久久成人精品视频| 国产精品亚洲综合专区片高清久久久| 国产精品久久精品| 亚洲午夜精品久久久久久app| 亚洲综合伊人久久大杳蕉| 99久久99久久久精品齐齐| 国产成人无码精品久久久免费| 久久青青草原精品国产不卡| 久久er99热精品一区二区| AA级片免费看视频久久| 久久人人爽人人人人爽AV| 亚洲国产精品久久久久久| 99久久香蕉国产线看观香| 久久99国产精品一区二区| 伊人久久大香线蕉av一区| 久久精品不卡| 色综合久久天天综合| 无码精品久久久久久人妻中字| 久久国产精品免费一区二区三区| 亚洲精品成人久久久| 国产L精品国产亚洲区久久| 中文字幕无码免费久久| 人妻系列无码专区久久五月天| 久久午夜电影网| 久久香蕉超碰97国产精品| 亚洲日本久久久午夜精品| 久久久久99精品成人片| 久久精品人人做人人爽电影| 久久99国产综合精品| 久久综合狠狠综合久久 | 久久无码中文字幕东京热| 久久电影网一区| 99久久99久久精品国产| 欧美精品一区二区精品久久| 青青热久久综合网伊人| 日韩欧美亚洲综合久久影院d3| 91精品观看91久久久久久| 久久青草国产手机看片福利盒子|