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

            A ring is composed of n (even number) circles as shown in diagram. Put natural numbers into each circle separately, and the sum of numbers in two adjacent circles should be a prime.


            Note: the number of first circle should always be 1.

            Input

            n (0 < n <= 16)

            Output

            The output format is shown as sample below. Each row represents a series of circle numbers in the ring beginning from 1 clockwisely and anticlockwisely. The order of numbers must satisfy the above requirements.


            You are to write a program that completes above process.

            Sample Input

            6
            8
            

            Sample Output

            Case 1:
            1 4 3 2 5 6
            1 6 5 2 3 4
            Case 2:
            1 2 3 8 5 6 7 4
            1 2 5 8 3 4 7 6
            1 4 7 6 5 8 3 2
            1 6 7 4 3 8 5 2
            


            很經典的深搜,啟發
            1,預處理非常重要,
            (1),先求出所有的prime數最大 16+16,bool isprime[32],
            (2)由于已經給出范圍,我們可以先求出1-19的每個數下一個可能的取值,例如15,下一個可以取2,4,------兩重for循環,可以避免搜索時重復判斷。
            2,用一個數組記錄使輸出的有序,op[n]與dfs(int begin,int n)中n對應
             if( bp[t] )
                   {
                    op[o] = t ;
                    o ++ ;
                    bp[t] = false ; 
                    dfs( t , n );//
                    o -- ;
                    bp[t] = true ;
                   } 
            posted on 2009-07-11 23:24 luis 閱讀(316) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久人妻少妇嫩草AV无码专区| 99久久国产热无码精品免费| 久久久久亚洲av成人无码电影| 国产成人精品久久亚洲高清不卡 | 国产精品久久久久久久人人看| 久久SE精品一区二区| 亚洲精品美女久久久久99| 国产精品毛片久久久久久久 | 久久妇女高潮几次MBA| 88久久精品无码一区二区毛片 | 久久精品国产亚洲AV无码娇色 | 久久久久人妻精品一区| 夜夜亚洲天天久久| 无码人妻久久一区二区三区| 久久艹国产| 国产精品久久亚洲不卡动漫| 伊人久久大香线蕉亚洲| 久久夜色撩人精品国产| 久久综合久久久| 色综合久久无码中文字幕| 午夜精品久久久久成人| 热99re久久国超精品首页| 久久人人爽爽爽人久久久| 精品久久久久久国产| 伊人久久大香线蕉综合网站| 99久久精品免费观看国产| 欧美久久精品一级c片片| 国产精品久久久亚洲| 欧洲精品久久久av无码电影| 亚洲中文字幕无码一久久区| 久久婷婷色综合一区二区| 色欲综合久久躁天天躁| 精品无码人妻久久久久久 | 久久精品无码一区二区WWW| 思思久久99热只有频精品66| 一级女性全黄久久生活片免费| 久久久久综合中文字幕| 精品久久久久中文字幕一区| 久久精品国产99国产精品| 91精品国产91久久久久久青草| 国产亚洲欧美精品久久久|