• <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久久精品免费看国产一区二区三区 | 7777久久久国产精品消防器材| 久久99精品久久久久久齐齐| 国产精品九九久久免费视频| 亚洲国产综合久久天堂| 国内精品久久久久影院优| 国产精自产拍久久久久久蜜| 久久婷婷色香五月综合激情| 99精品国产在热久久无毒不卡| 久久久久久av无码免费看大片| 狠狠色丁香久久婷婷综合| 日本久久久久久中文字幕| 午夜视频久久久久一区| 国产精品美女久久久久网| 免费一级做a爰片久久毛片潮| 少妇久久久久久被弄高潮| 精品欧美一区二区三区久久久| 蜜臀av性久久久久蜜臀aⅴ麻豆| 国产精品欧美久久久久天天影视| 久久精品国产清自在天天线| 久久精品综合网| www亚洲欲色成人久久精品| 久久91精品国产91| 中文字幕亚洲综合久久| 亚洲色欲久久久综合网东京热| 久久精品亚洲精品国产欧美| 精品免费tv久久久久久久| 久久香综合精品久久伊人| 思思久久99热免费精品6| 国产精品激情综合久久 | 精品一区二区久久久久久久网站| 天天做夜夜做久久做狠狠| 国产精品成人精品久久久| 99久久国产亚洲高清观看2024 | 一本色道久久88综合日韩精品| 久久精品人人做人人爽电影| 精品综合久久久久久97| 污污内射久久一区二区欧美日韩| 国产69精品久久久久99| 精品久久久久久无码人妻蜜桃| 久久九九全国免费|