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

            想不到更有效的方法,數據量不大,直接暴力

            #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

            導航

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

            統計

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久99久久99精品免视看动漫| 欧美性猛交xxxx免费看久久久| 久久久久青草线蕉综合超碰| 人妻精品久久无码区| 国产精品岛国久久久久| 天天影视色香欲综合久久| 亚洲AV无码久久精品狠狠爱浪潮| 久久香蕉国产线看观看99| 亚洲国产精品综合久久网络| 嫩草伊人久久精品少妇AV| 久久综合久久性久99毛片| 久久精品国产久精国产思思| 久久亚洲AV无码西西人体| 国产婷婷成人久久Av免费高清| 四虎国产精品成人免费久久| 精品人妻久久久久久888| 久久久久久国产a免费观看不卡| 无码专区久久综合久中文字幕| 久久精品国产一区二区| 久久久久久久尹人综合网亚洲| 99久久夜色精品国产网站 | 亚洲中文字幕久久精品无码APP| 久久无码人妻一区二区三区| 久久乐国产综合亚洲精品| 激情久久久久久久久久| MM131亚洲国产美女久久| 人妻精品久久无码区| 亚洲国产精品高清久久久| 国产成人综合久久精品红| 免费一级做a爰片久久毛片潮| 久久美女网站免费| 色噜噜狠狠先锋影音久久| 秋霞久久国产精品电影院| 女人香蕉久久**毛片精品| 久久99精品国产99久久6男男| 99久久国语露脸精品国产| 99久久精品国产高清一区二区| 国产精品久久亚洲不卡动漫| 伊人久久大香线蕉精品| 久久国产成人午夜aⅴ影院| 久久综合亚洲色HEZYO国产|