• <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的每個數(shù)下一個可能的取值,例如15,下一個可以取2,4,------兩重for循環(huán),可以避免搜索時重復(fù)判斷。
            2,用一個數(shù)組記錄使輸出的有序,op[n]與dfs(int begin,int n)中n對應(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 閱讀(308) 評論(0)  編輯 收藏 引用 所屬分類: 搜索
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品人人做人人妻人人玩| 久久精品无码一区二区三区日韩| 99久久国产综合精品五月天喷水| 人人狠狠综合久久亚洲88| 精品国产乱码久久久久久呢| 精品熟女少妇aⅴ免费久久| 亚洲欧美精品一区久久中文字幕| 熟妇人妻久久中文字幕| 无码任你躁久久久久久| 久久九九亚洲精品| 久久91综合国产91久久精品 | 2021久久精品国产99国产精品| 亚洲欧美国产日韩综合久久| 一本色道久久88加勒比—综合| 久久精品视屏| 老男人久久青草av高清| 午夜视频久久久久一区| 久久er国产精品免费观看8| 国产午夜精品久久久久九九电影 | 久久精品无码一区二区app| 久久国产精品二国产精品| 久久精品国产一区二区三区不卡| 亚洲国产精品久久久久婷婷老年| 国产69精品久久久久9999| 久久777国产线看观看精品| 亚洲一区二区三区日本久久九| 99久久综合狠狠综合久久| 午夜欧美精品久久久久久久| 日本久久久久亚洲中字幕| 77777亚洲午夜久久多喷| 94久久国产乱子伦精品免费| 国产99久久九九精品无码| 88久久精品无码一区二区毛片 | 超级碰碰碰碰97久久久久| 色婷婷噜噜久久国产精品12p| 97精品伊人久久大香线蕉| 国内精品久久久久久中文字幕| 久久免费看黄a级毛片| 久久精品国产99久久无毒不卡| 无码8090精品久久一区| 四虎国产精品免费久久久|