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

            pku1920 Towers of Hanoi 河內塔問題

            給出河內塔的中間狀態,求將所有盤子摞到一起的的最小步數。
            先貼程序
             1 import java.util.*;
             2 import java.io.*;
             3 public class Main {
             4 
             5     /**
             6      * @param args
             7      */
             8     static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
             9     static final int nextInt() throws Exception
            10     {
            11         in.nextToken();
            12         return (int)in.nval;
            13     }
            14     public static void main(String[] args) throws Exception{
            15         
            16         int num=nextInt();
            17         int step[]=new int[num+1];
            18         int id[]=new int[num+1];
            19         step[1]=1;
            20         for(int i=2;i<=num;i++)
            21             step[i]= (step[i-1]<<1)%1000000;
            22         ArrayList<Integer> data[]=new ArrayList[3];
            23         for(int i=0;i<3;i++)
            24             data[i]=new ArrayList<Integer>();
            25         int a=nextInt(),b=nextInt(),c=nextInt();
            26         while((a--)!=0)
            27             id[nextInt()]=0;
            28         while((b--)!=0)
            29             id[nextInt()]=1;
            30         while((c--)!=0)
            31             id[nextInt()]=2;
            32         int s=id[num],e=s,mid=0,total=0;
            33         for(int i=num;i>=1;)
            34         {
            35             if(s!=e)
            36             {
            37                 total=(step[i]+total)%1000000;
            38                 e=mid;
            39             }
            40             s=id[--i];
            41             mid=3-s-e;
            42         }
            43         System.out.println(id[num]+1);
            44         System.out.println(total);
            45         
            46         
            47         
            48     }
            49 
            50 }
            51 


            posted on 2010-11-01 02:31 yzhw 閱讀(206) 評論(0)  編輯 收藏 引用 所屬分類: combination mathdata struct

            <2011年6月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            導航

            統計

            公告

            統計系統

            留言簿(1)

            隨筆分類(227)

            文章分類(2)

            OJ

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            99久久综合狠狠综合久久| 2021国产精品久久精品| 精品久久久久香蕉网| 99久久综合狠狠综合久久| 日韩欧美亚洲综合久久影院Ds| 中文字幕精品无码久久久久久3D日动漫 | 久久精品国产亚洲一区二区| 国产精品久久久久乳精品爆| 狠狠色丁香久久婷婷综合| 久久精品国产只有精品2020| 91麻豆国产精品91久久久| 高清免费久久午夜精品| 亚洲乱码日产精品a级毛片久久 | 久久精品国产亚洲综合色| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久国产综合精品五月天| 精品多毛少妇人妻AV免费久久 | 久久久久久久综合综合狠狠| 欧美一区二区三区久久综| 精品久久久久中文字幕一区| 无码专区久久综合久中文字幕| 很黄很污的网站久久mimi色| 久久久久99精品成人片直播| 久久天天日天天操综合伊人av| 精品久久久噜噜噜久久久| 久久这里的只有是精品23| 久久国产精品视频| 色综合久久最新中文字幕| 亚洲伊人久久大香线蕉综合图片| 免费精品久久久久久中文字幕 | 国产成人精品久久| 日产久久强奸免费的看| 国内精品久久久久久久亚洲| 久久这里只精品国产99热| 久久久精品人妻一区二区三区四| 久久久噜噜噜久久中文字幕色伊伊| 久久久久久国产a免费观看不卡| 国产99久久久国产精品~~牛| 欧美精品一区二区精品久久| 久久精品国产亚洲麻豆| 国产精品gz久久久|