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

            USACO 1.2 Dual Palindromes

            想不到更有效的方法,數(shù)據(jù)量不大,直接暴力

            #include <iostream>
            #include 
            <fstream>

            using namespace std;

            ifstream fin(
            "dualpal.in");
            ofstream fout(
            "dualpal.out");

            #ifdef _DEBUG
            #define out cout
            #define in cin
            #else
            #define out fout
            #define in fin
            #endif

            int buf[33];

            bool isPal(int num, int base)
            {
                
            int cnt = 0;
                
            while(num!=0){
                    buf[cnt
            ++= num%base;
                    num
            /=base;
                }

                
            int max = (cnt-1)/2;

                
            for(int i=0;i<=max;++i){
                    
            if(buf[i]!=buf[cnt-1-i])
                        
            return false;
                }

                
            return true;
            }

            bool duaPal(int num)
            {
                
            int cnt = 0;
                
            for(int base=2;base<=10;++base){
                    
            if( isPal(num,base) ){
                        cnt
            ++;
                        
            if(cnt==2)
                            
            return true;
                    }
                }

                
            return false;
            }

            void solve()
            {
                
            int n,s;
                
            in>>n>>s;

                
            while(n--){
                   
            while(!duaPal(++s));
                   
            out<<s<<endl;
                }        
            }

            int main(int argc,char *argv[])
            {
              solve(); 
              
            return 0;
            }





            附原題:
            Dual Palindromes
            Mario Cruz (Colombia) & Hugo Rickeboer (Argentina)

            A number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321 is a palindrome; the number 77778 is not. Of course, palindromes have neither leading nor trailing zeroes, so 0220 is not a palindrome.

            The number 21 (base 10) is not palindrome in base 10, but the number 21 (base 10) is, in fact, a palindrome in base 2 (10101).

            Write a program that reads two numbers (expressed in base 10):

            • N (1 <= N <= 15)
            • S (0 < S < 10000)
            and then finds and prints (in base 10) the first N numbers strictly greater than S that are palindromic when written in two or more number bases (2 <= base <= 10).

            Solutions to this problem do not require manipulating integers larger than the standard 32 bits.

            PROGRAM NAME: dualpal

            INPUT FORMAT

            A single line with space separated integers N and S.

            SAMPLE INPUT (file dualpal.in)

            3 25

            OUTPUT FORMAT

            N lines, each with a base 10 number that is palindromic when expressed in at least two of the bases 2..10. The numbers should be listed in order from smallest to largest.

            SAMPLE OUTPUT (file dualpal.out)

            26
            27
            28


            posted on 2009-06-05 15:09 YZY 閱讀(1057) 評論(0)  編輯 收藏 引用 所屬分類: AlgorithmUSACO

            導(dǎo)航

            <2009年6月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            統(tǒng)計

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            国产精品乱码久久久久久软件 | 精品国产91久久久久久久| 欧美黑人激情性久久| 亚洲av伊人久久综合密臀性色| 日日噜噜夜夜狠狠久久丁香五月 | Xx性欧美肥妇精品久久久久久| 久久国产三级无码一区二区| 久久只这里是精品66| 99久久这里只有精品| 亚洲国产成人精品无码久久久久久综合| 精品国产日韩久久亚洲| 日本免费久久久久久久网站| 区久久AAA片69亚洲| 国产精品久久久久乳精品爆| 欧美牲交A欧牲交aⅴ久久| 国产成人久久久精品二区三区| 久久99热这里只有精品66| 国产一区二区三区久久精品| 久久久无码精品亚洲日韩京东传媒| 久久99国产精品99久久| 色综合久久久久久久久五月 | 亚洲精品乱码久久久久久蜜桃图片| 一本一道久久精品综合| 久久ZYZ资源站无码中文动漫 | 久久夜色精品国产噜噜麻豆| 亚洲性久久久影院| 日本国产精品久久| 久久久91人妻无码精品蜜桃HD| 久久er国产精品免费观看2| 久久精品无码一区二区WWW| 性做久久久久久久久浪潮| 美女久久久久久| 久久精品国产亚洲精品| 国产真实乱对白精彩久久| 国产精品久久久久久福利漫画| 久久国产精品77777| 久久精品国产亚洲av水果派| 91精品国产高清久久久久久io| 精品久久久久久久无码| 99国产欧美精品久久久蜜芽| 精品久久久久中文字幕日本|