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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧美亚洲国产精品久久高清| 久久久精品人妻一区二区三区四| 亚洲精品乱码久久久久久| 久久久久国产一级毛片高清版| 久久久久久精品免费看SSS| 蜜桃麻豆www久久国产精品| 国产精品无码久久四虎| 久久综合久久综合久久综合| 久久99精品国产麻豆| 久久国产高潮流白浆免费观看| 狠狠色丁香久久婷婷综合| 久久99九九国产免费看小说| 久久伊人精品一区二区三区| 久久人做人爽一区二区三区| 国内精品人妻无码久久久影院导航 | 久久精品国产亚洲AV无码偷窥| 亚洲欧美日韩久久精品第一区| 久久国语露脸国产精品电影 | 久久99热这里只频精品6| 久久午夜福利无码1000合集| 一本色道久久88—综合亚洲精品| 中文字幕无码免费久久| 国产91色综合久久免费| 免费国产99久久久香蕉| 精品久久人人做人人爽综合| 久久夜色撩人精品国产| av色综合久久天堂av色综合在 | 国产成人久久激情91| 国产伊人久久| 精品国产乱码久久久久久呢| 久久久久久a亚洲欧洲aⅴ| 欧美性大战久久久久久| 久久精品国产亚洲AV麻豆网站| 99热热久久这里只有精品68| 久久伊人中文无码| 亚洲人成精品久久久久| 国产呻吟久久久久久久92| 奇米影视7777久久精品人人爽| 国产精品美女久久久m| 7777精品伊人久久久大香线蕉| 久久99精品国产一区二区三区|