• <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 閱讀(1058) 評論(0)  編輯 收藏 引用 所屬分類: AlgorithmUSACO

            導航

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

            統計

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久996热精品xxxx| 亚洲精品乱码久久久久66| 国产精品99久久久久久人| 91精品国产高清91久久久久久| www性久久久com| 久久久久亚洲爆乳少妇无| 久久99精品国产自在现线小黄鸭 | 久久精品国产亚洲Aⅴ蜜臀色欲| 最新久久免费视频| 品成人欧美大片久久国产欧美... 品成人欧美大片久久国产欧美 | 久久亚洲国产精品一区二区| 国产亚洲美女精品久久久2020| 99国产精品久久久久久久成人热| 国产免费久久久久久无码| 日韩AV无码久久一区二区| 欧美久久一区二区三区| 久久91亚洲人成电影网站| 久久水蜜桃亚洲av无码精品麻豆 | 伊人久久成人成综合网222| 久久久久亚洲AV无码永不| 久久精品国产AV一区二区三区 | 国产99久久九九精品无码| 色欲久久久天天天综合网| 久久www免费人成看国产片| 久久99热国产这有精品| 嫩草伊人久久精品少妇AV| 免费精品久久天干天干| 亚洲国产日韩欧美综合久久| 国产精品99久久久久久www| 久久国产色AV免费看| 亚洲综合日韩久久成人AV| 欧美精品九九99久久在观看| 中文字幕无码久久人妻| 久久精品无码一区二区app| 国产一区二区精品久久凹凸| 久久er热视频在这里精品| AV狠狠色丁香婷婷综合久久| 国内精品久久久久久99| 久久精品aⅴ无码中文字字幕不卡| 久久中文骚妇内射| 国产精品久久免费|