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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品人人做人人爽电影| 久久久久国产成人精品亚洲午夜| 99久久香蕉国产线看观香| 99久久综合国产精品免费 | 国产L精品国产亚洲区久久| 久久伊人中文无码| 久久婷婷国产综合精品| 久久一区二区三区99| 久久天堂AV综合合色蜜桃网| 久久丝袜精品中文字幕| 久久国产免费观看精品| 亚洲中文字幕无码久久2017 | 人妻无码久久精品| 一本久久久久久久| 久久久久AV综合网成人| 最新久久免费视频| 99久久婷婷国产一区二区| 久久99国内精品自在现线| 久久久久高潮综合影院| 国产成人无码精品久久久久免费 | 久久国产免费观看精品| 久久99精品国产麻豆宅宅| 亚洲精品无码久久不卡| 久久99久久成人免费播放| 欧美激情精品久久久久| 国内精品久久人妻互换| 久久亚洲美女精品国产精品| 天天影视色香欲综合久久| 国产女人aaa级久久久级| 办公室久久精品| AAA级久久久精品无码区| 亚洲精品高清久久| 国产99久久九九精品无码| 亚洲国产精品热久久| 国产成人久久777777| 久久久精品人妻无码专区不卡 | 成人国内精品久久久久影院| 成人免费网站久久久| 91精品国产91久久久久久青草 | 人妻少妇久久中文字幕一区二区| 久久综合鬼色88久久精品综合自在自线噜噜 |