• <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 閱讀(207) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年6月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            性色欲网站人妻丰满中文久久不卡| 久久精品人人做人人爽电影| 欧美久久一区二区三区| 久久人妻少妇嫩草AV无码蜜桃 | 久久精品国产精品青草app| 色综合色天天久久婷婷基地| 亚洲国产天堂久久综合| 精品熟女少妇a∨免费久久| 久久久久久噜噜精品免费直播| 青青草原综合久久大伊人| 97r久久精品国产99国产精| 久久这里只精品99re66| 精品熟女少妇av免费久久| 亚洲人AV永久一区二区三区久久| 国产精品美女久久久m| 亚洲精品国精品久久99热| 久久免费高清视频| 亚洲欧洲日产国码无码久久99| 国产女人aaa级久久久级| 国产精品99久久99久久久| 久久久久久久久66精品片| 99久久精品国产一区二区蜜芽| 99久久精品免费看国产一区二区三区 | 久久久久人妻一区精品| www性久久久com| 嫩草伊人久久精品少妇AV| 婷婷久久五月天| 亚洲国产高清精品线久久| 国产亚州精品女人久久久久久| 久久99精品久久久久子伦| 亚洲∧v久久久无码精品| 波多野结衣久久精品| 中文字幕无码久久人妻| 久久国产成人| 久久综合视频网站| 久久亚洲精品无码播放| 久久九色综合九色99伊人| 久久久久久毛片免费看| 亚洲国产精品无码久久久久久曰 | 久久免费小视频| 99久久综合国产精品二区|