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


            很經(jīng)典的深搜,啟發(fā)
            1,預(yù)處理非常重要,
            (1),先求出所有的prime數(shù)最大 16+16,bool isprime[32],
            (2)由于已經(jīng)給出范圍,我們可以先求出1-19的每個(gè)數(shù)下一個(gè)可能的取值,例如15,下一個(gè)可以取2,4,------兩重for循環(huán),可以避免搜索時(shí)重復(fù)判斷。
            2,用一個(gè)數(shù)組記錄使輸出的有序,op[n]與dfs(int begin,int n)中n對(duì)應(yīng)
             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) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 搜索
            <2012年4月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            常用鏈接

            留言簿(3)

            隨筆分類(lèi)

            隨筆檔案

            文章分類(lèi)

            文章檔案

            友情鏈接

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            麻豆一区二区99久久久久| 一本一道久久综合狠狠老| 日韩人妻无码精品久久久不卡| 热久久国产欧美一区二区精品| 久久国产综合精品五月天| 国产69精品久久久久9999| 精品无码久久久久久国产| 国产香蕉97碰碰久久人人| 久久精品国产只有精品66| 欧美亚洲日本久久精品| 久久国内免费视频| 久久国产色AV免费观看| 国产精品久久网| 久久国产成人亚洲精品影院| 久久这里有精品视频| 久久人与动人物a级毛片| 久久人爽人人爽人人片AV| 久久精品免费一区二区三区| 久久99国产一区二区三区| 怡红院日本一道日本久久 | 99久久精品国产免看国产一区| 精品国产福利久久久| 久久久噜噜噜久久| 亚洲国产精品18久久久久久| 九九精品99久久久香蕉| 久久成人精品| 亚洲AV无码久久| 久久久久久久综合综合狠狠| 久久精品国产2020| 国内精品久久久久久久影视麻豆| 久久婷婷五月综合97色直播| 久久免费小视频| 伊人色综合久久天天人手人婷 | 久久久久亚洲AV无码专区桃色| 日本WV一本一道久久香蕉| 久久精品国产一区| 久久亚洲私人国产精品| 久久亚洲AV永久无码精品| 2022年国产精品久久久久| 97视频久久久| 久久综合给合综合久久|