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

            學習心得(code)

            superlong@CoreCoder

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

            公告

            文字可能放在http://blog.csdn.net/superlong100,此處存放代碼

            常用鏈接

            留言簿(4)

            我參與的團隊

            搜索

            •  

            最新隨筆

            最新評論

            • 1.?re: Poj 1279
            • 對于一個凹多邊形用叉積計算面積 后能根據結果的正負來判斷給的點集的時針方向?
            • --bsshanghai
            • 2.?re: Poj 3691
            • 你寫的這個get_fail() 好像并是真正的get_fail,也是說fail指向的串并不是當前結點的子串。為什么要這樣弄呢?
            • --acmer1183
            • 3.?re: HDU2295[未登錄]
            • 這個是IDA* 也就是迭代加深@ylfdrib
            • --superlong
            • 4.?re: HDU2295
            • 評論內容較長,點擊標題查看
            • --ylfdrib
            • 5.?re: HOJ 11482
            • 呵呵..把代碼發在這里很不錯..以后我也試試...百度的編輯器太爛了....
            • --csuft1

            閱讀排行榜

            評論排行榜

            #include <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>

            int  num[9], ini;
            int  L;
            bool flag;
            int  mv[4= {13-1-3};//right down left up
            int  path[1001];
            int  len;
            char map[4= {'r''d''l''u'};

            void read()
            {
                
            char s[2];
                
            for(int i = 0; i < 9; i ++)
                {
                    scanf(
            "%s", s);
                    
            if(s[0== 'x') {num[i] = 0; ini = i;}
                    
            else            num[i] = s[0- '0';
                }
            }

            bool ok()   // jud for destination
            {
                
            for(int i = 0; i < 8; i ++)
                    
            if(num[i] != i + 1return false;
                
            return true;
            }

            bool jud(int pos, int i)  //jud for right
            {
                
            if(pos % 3 != 2 && i == 0return true;
                
            if(pos < 6 && i == 1return true;
                
            if(pos % 3 != 0 && i == 2return true;
                
            if(pos > 2 && i == 3return true;
                
            return false;
            }

            int cal()
            {
                
            int cost = 0;
                
            for(int i = 0; i < 9; i ++)
                
            if(num[i])
                    cost 
            += abs((num[i] - 1)%3 - i%3+ abs((num[i] - 1)/3 - i/3);
                
            return cost;
            }

            void dfs(int pos, int deep)
            {
                
            int i, J, cost;
                
            if(deep == L)
                {
                    
            if(ok()) flag = true;
                    
            return;
                }
                
            for(i = 0; i < 4; i ++)
                {
                    
            if(!jud(pos, i)) continue;
                    num[pos] 
            ^= num[pos + mv[i]] ^= num[pos] ^= num[pos + mv[i]];//state change
                    
                    cost 
            = cal();
                    
            if(cost + deep  < L)
                    {
                        path[len
            ++= i;
                        dfs(pos 
            + mv[i], deep + 1);
                        
            if(flag) return;
                        len 
            --;
                    }
                    num[pos] 
            ^= num[pos + mv[i]] ^= num[pos] ^= num[pos + mv[i]];//state again
                }    
            }

            void out()
            {
                
            int i;
                
            //printf("%d\n",len);
                for(i = 0; i < len; i ++)
                    printf(
            "%c", map[path[i]]);
                puts(
            "");
            }

            int main()
            {
                read();
                L 
            = 1; len = 0;
                flag 
            = false;
                
            while(!flag)
                {
                    dfs(ini, 
            0);
                    L 
            ++;
                }
                
            out();
            }

            posted on 2009-09-03 01:19 superlong 閱讀(140) 評論(0)  編輯 收藏 引用
            国产99精品久久| 亚洲精品无码久久毛片| 狠狠色丁香婷婷综合久久来| 久久精品成人免费网站| 精品久久久久久99人妻| 欧美日韩精品久久久久| 国产成人精品久久亚洲| 久久精品国产亚洲精品2020| 日韩欧美亚洲综合久久影院d3| 一本久道久久综合狠狠爱| 麻豆精品久久久一区二区| 久久精品国产精品亚洲精品| 久久福利青草精品资源站| 亚洲精品乱码久久久久久蜜桃图片 | 免费精品久久久久久中文字幕| 久久久久无码精品国产| 亚洲欧美一级久久精品| 日本三级久久网| 久久人人爽人人爽人人AV东京热| 亚洲国产成人久久综合碰| 久久久久国色AV免费看图片| 久久这里只有精品久久| 精品国产99久久久久久麻豆| 伊人久久大香线蕉综合5g| 久久国产香蕉一区精品| 97超级碰碰碰久久久久| 无码人妻久久一区二区三区免费丨 | 久久国产精品99国产精| 久久国产精品成人片免费| 久久久久久国产精品无码下载| 久久婷婷国产剧情内射白浆| 一级女性全黄久久生活片免费 | 久久91精品国产91| 久久久久97国产精华液好用吗| 久久AⅤ人妻少妇嫩草影院| 国产99久久九九精品无码| 人妻少妇精品久久| 一级做a爰片久久毛片毛片| 午夜精品久久久久| 久久人人爽人人爽人人片av高请 | 久久se精品一区二区影院|