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

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數據加載中……

            poj1426(bfs、dp)

            http://poj.org/problem?id=1426

            bfs:剛剛拿到想把所有數給用字符串保存,這樣最多可有100個01呢。
            一直都覺得這樣樸素的算法很惡心,就去吃飯去了,我嚓,12點吃早飯。
            突然想到其實我的串可以que[]里存0和1嘛,然后索引一下就好了于是乎,行了,嘿嘿。這樣遞推過去的,其實應該是可以整出了dp狀態轉移方程的哈,等會想想呢
            bfs:
            32MS
            #include<stdio.h>
            #include
            <string.h>
            #include
            <math.h>
            int n;
            int que[1000005],pre[1000005],q[1000005],ans[205];//que[] 0、1,q[]當前余數,pre[]前驅。
            int bfs()
            {
                
            int head,tail,now,next,i;
                head
            =0;tail=1;que[1]=1;pre[1]=0;q[1]=1;
                
            while (head<tail)
                {
                    now
            =q[++head]*10;
                    
            for (i=0;i<=1 ;i++ )
                    {
                        next
            =now+i;
                        tail
            ++;
                        que[tail]
            =i;
                        q[tail]
            =next%n;
                        pre[tail]
            =head;
                        
            if (!q[tail])
                            
            return tail;
                    }
                }
            }
            int main()
            {
                
            int i,k;
                
            while (scanf("%d",&n)==1&&n)
                {
                    i
            =bfs();
                    k
            =0;
                    
            while (i)
                    {
                        ans[
            ++k]=que[i];
                        i
            =pre[i];
                    }
                    
            for (i=k;i>=1 ;i-- )
                        printf(
            "%d",ans[i]);
                    printf(
            "\n");
                }
                
            return 0;
            }
            同學用的long long 也過了,容我研究研究哈。
            long long:我暈,居然跑了110MS
            dp會跑多久么?

            posted on 2012-04-02 14:16 wangs 閱讀(318) 評論(0)  編輯 收藏 引用 所屬分類: ACM-模擬

            国产成人无码精品久久久性色 | 亚洲欧美成人久久综合中文网| 久久精品国产影库免费看| 国产99久久九九精品无码| 久久综合久久鬼色| 亚洲色大成网站WWW久久九九| 久久精品国产91久久麻豆自制| 久久996热精品xxxx| 九九精品99久久久香蕉| 亚洲国产精品成人久久蜜臀| 2020久久精品国产免费| 一本一本久久A久久综合精品| 亚洲成人精品久久| 精品久久久久中文字幕日本| 久久综合一区二区无码| 国产精品久久久久无码av| 77777亚洲午夜久久多喷| 久久久久人妻一区精品| 久久精品国产91久久麻豆自制| 中文精品久久久久人妻不卡| 一级做a爰片久久毛片看看| 国产亚州精品女人久久久久久 | 久久婷婷五月综合国产尤物app| 97超级碰碰碰久久久久| 97久久婷婷五月综合色d啪蜜芽 | 国产精品久久久久乳精品爆| 久久中文骚妇内射| 2020久久精品亚洲热综合一本| 久久久久久久久久久免费精品| 久久久久久久尹人综合网亚洲| 久久久av波多野一区二区| 少妇人妻88久久中文字幕| 国产精品久久久久久久app | 精品精品国产自在久久高清| 久久综合给合久久狠狠狠97色| 久久精品国产清自在天天线| 久久中文字幕人妻熟av女| 久久强奷乱码老熟女网站| 中文字幕无码精品亚洲资源网久久| 亚洲国产精品综合久久网络| 亚洲国产成人久久综合碰|