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

            O(1) 的小樂

            Job Hunting

            公告

            記錄我的生活和工作。。。
            <2011年1月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            統計

            • 隨筆 - 182
            • 文章 - 1
            • 評論 - 41
            • 引用 - 0

            留言簿(10)

            隨筆分類(70)

            隨筆檔案(182)

            文章檔案(1)

            如影隨形

            搜索

            •  

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            SRM 303U

            DIV2 1000

            使用一個整數的所有素因子能否組成一個回文字符串?要求數出在A與B之間滿足要求的這樣的整數的數目。

            暴力解決就OK,next_permutation 的復雜度要計算準確!不是簡單的數目的階乘!!

             

            template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
            bool judge(string c)
            {
                for(int i=0; i<=c.size()/2; i++)
                {
                    if(c[i]!= c[c.size()-i-1]) return false;
                }
                return true;
            }
            bool func(int num)
            {
                vector<string> p;
                int temp = num;
                for(int i=2; i*i<=num; i++)
                {
                    while(temp % i==0)
                    {
                        p.push_back(toString(i));
                        temp/=i;
                    }
                }
                if(temp!=1) p.push_back(toString(temp));
                sort(p.begin(), p.end());
                do
                {
                    string c;
                    for(int i=0; i<p.size(); i++) c+=p[i];
                    if(judge(c)){ for(int i=0; i<p.size(); i++) cout<<p[i]<<" "; cout<<endl; return true;}
                }while(next_permutation(p.begin(), p.end()));
                return false;
            }
            class PrimePalindromic
            {
                public:
                    int count(int A, int B)
                    {
                        int ret = 0;
                        for(int i=A; i<=B; i++)
                            if(func(i)){ cout<<" "<<i<<endl;  ret++;}
                        return ret;
                    }
            };

            posted on 2012-06-01 16:39 Sosi 閱讀(147) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm

            統計系統
            久久久这里有精品| 免费国产99久久久香蕉| 亚洲欧美国产精品专区久久| 色狠狠久久综合网| 久久99精品国产麻豆| 色综合久久最新中文字幕| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 国产精品久久久久无码av| 久久香蕉国产线看观看乱码| 一级女性全黄久久生活片免费 | 热re99久久精品国99热| 国产视频久久| 麻豆AV一区二区三区久久| 久久久久久亚洲精品不卡 | 狠狠色婷婷久久一区二区三区| 国产高清美女一级a毛片久久w | 狼狼综合久久久久综合网| 人人狠狠综合久久亚洲高清| 精品久久久久久综合日本| 久久九九久精品国产免费直播| 久久91精品国产91久久麻豆| 伊人久久大香线蕉亚洲五月天| 亚洲国产天堂久久综合| 精品久久久无码中文字幕| 亚洲国产精久久久久久久| 国产午夜免费高清久久影院| 精品人妻伦九区久久AAA片69| 久久有码中文字幕| 久久久久一本毛久久久| 精品无码久久久久久久久久| 91精品国产91久久久久久蜜臀| 91精品国产色综合久久| 久久久久人妻一区精品色| 久久精品青青草原伊人| 欧美亚洲国产精品久久| 思思久久99热只有频精品66| 亚洲欧洲久久久精品| 久久精品国产亚洲AV久| 久久精品国产99国产精品亚洲| 亚洲午夜久久久久久久久久| 久久久久久久精品妇女99|