• <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)論排行榜

            国产精品久久久久无码av| 亚洲精品tv久久久久| 久久精品这里热有精品| 婷婷久久综合九色综合绿巨人| 日本WV一本一道久久香蕉| 91精品国产综合久久久久久| 精品久久久久久无码中文字幕| 久久国产亚洲精品| 99久久婷婷国产一区二区| 无码精品久久久久久人妻中字| 久久久久久久久久久久久久| 欧美一区二区三区久久综 | 2021精品国产综合久久| 少妇久久久久久被弄到高潮| 亚洲国产精品成人AV无码久久综合影院 | 99久久国语露脸精品国产| 久久精品国产亚洲综合色| 久久91精品久久91综合| 狠狠色丁香久久综合五月| 久久国产精品成人片免费| 国产精品久久久久久一区二区三区| 久久久国产精华液| 久久精品国产亚洲77777| 99热都是精品久久久久久| 热re99久久精品国产99热| 情人伊人久久综合亚洲| 亚洲午夜精品久久久久久app| 久久久久亚洲爆乳少妇无| 无码国产69精品久久久久网站| 久久久久女人精品毛片| 久久夜色撩人精品国产小说| 亚洲成av人片不卡无码久久| 亚洲色欲久久久久综合网| 午夜人妻久久久久久久久| 久久夜色tv网站| 久久精品一区二区三区AV| 久久久国产一区二区三区| 亚洲精品白浆高清久久久久久| 久久国产精品二国产精品| 亚洲国产精品无码久久久不卡 | 久久精品国产久精国产果冻传媒|