• <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麻豆图片| 99久久国语露脸精品国产| 蜜臀久久99精品久久久久久小说| 精品国产乱码久久久久久浪潮 | 久久久久亚洲精品天堂久久久久久| 国产精品久久久久久久久久影院| 国产精品成人精品久久久| 久久亚洲中文字幕精品有坂深雪 | 一本久久免费视频| 国产精品久久久久9999| 99久久做夜夜爱天天做精品| 久久综合久久综合久久| 97久久精品人妻人人搡人人玩| 开心久久婷婷综合中文字幕| 精品久久久久久国产潘金莲| 麻豆AV一区二区三区久久 | 久久av无码专区亚洲av桃花岛| 无码任你躁久久久久久久| 草草久久久无码国产专区| 久久久免费精品re6| 久久99热这里只频精品6| 久久精品无码一区二区三区日韩| 久久国产成人午夜aⅴ影院 | 色妞色综合久久夜夜| 偷窥少妇久久久久久久久| 亚洲色欲久久久久综合网| 久久国产福利免费| 久久综合色之久久综合| 久久亚洲高清综合| 久久久久99精品成人片牛牛影视| 欧美国产精品久久高清| 国产精品成人精品久久久| 久久亚洲高清综合| 欧美黑人激情性久久| 亚洲va久久久噜噜噜久久狠狠| 996久久国产精品线观看|