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

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            URAL——1012——(遞推+高精度)

            Posted on 2008-08-15 15:58 Hero 閱讀(192) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
            /*
            ID: wangzha4
            LANG: C++
            TASK: palsquare
            */
            //JUDGE_ID: 65448BI

            //f[1] = 10 ;--特殊
            //f[2] = 9 * 10 ;
            //f[3] = 9 * ( 9 + 9 *10 ) ;
            //f[n] = 9*(f[n-2] + f[n-1]) ;
            //f[n]表示以第n個數字開頭最多能構建滿足條件的解的個數

            #include 
            <iostream>
            using namespace std ;

            #define unllong unsigned long long 
            #define unint unsigned int
            #define printline  printf( "\n" ) 
            typedef 
            long long llong ;
            //const double PI = 2.0 * acos( 0.0 ) ;

            const int Base=1000000000;
            const int Capacity=500;
            const int INF = 1000000 ;
            const int size = 155 ;

            struct BigInt{
                
            int Len;
                
            int Data[Capacity];
                BigInt():Len(
            0){}
                BigInt(
            const BigInt &V):Len(V.Len){memcpy(Data,V.Data,Len*sizeof*Data);}
                BigInt(
            int V):Len(0){for(;V>0;V/=Base) Data[Len++]=V%Base;}
                BigInt 
            &operator=(const BigInt &V){Len=V.Len;memcpy(Data,V.Data,Len*sizeof*Data);return *this;}
                
            int &operator[](int Index){return Data[Index];}
                
            int operator[](int Index)const{return Data[Index];}
            };

            int compare(const BigInt &A,const BigInt &B){
                
            if(A.Len!=B.Len) return A.Len>B.Len ? 1:-1;
                
            int i;
                
            for(i=A.Len-1;i>=0 && A[i]==B[i];i--);
                
            if(i<0)return 0;
                
            return A[i]>B[i] ? 1:-1;
            }

            BigInt 
            operator+(const BigInt &A,const BigInt &B){
                
            int i,Carry(0);
                BigInt R;
                
            for(i=0;i<A.Len||i<B.Len||Carry>0;i++){
                    
            if(i<A.Len) Carry+=A[i];
                    
            if(i<B.Len) Carry+=B[i];;
                    R[i]
            =Carry%Base;
                    Carry
            /=Base;
                }
                R.Len
            =i;
                
            return R;
            }

            BigInt 
            operator-(const BigInt &A,const BigInt &B){
                
            int i,Carry(0);
                BigInt R;
                R.Len
            =A.Len;
                
            for(i=0;i<R.Len;i++){
                    R[i]
            =A[i]-Carry;
                    
            if(i<B.Len) R[i]-=B[i];
                    
            if(R[i]<0) Carry=1,R[i]+=Base;
                    
            else Carry=0;
                }
                
            while(R.Len>0&&R[R.Len-1]==0) R.Len--;
                
            return R;
            }

            BigInt 
            operator*(const BigInt &A,const int &B){
                
            int i;
                llong Carry(
            0);
                BigInt R;
                
            for(i=0;i<A.Len||Carry>0;i++){
                    
            if(i<A.Len) Carry+=llong(A[i])*B;
                    R[i]
            =Carry%Base;
                    Carry
            /=Base;
                }
                R.Len
            =i;
                
            return R;
            }

            istream 
            &operator>>(istream &In,BigInt &V){
                
            char Ch;
                
            for(V=0;In>>Ch;){
                    V
            =V*10+(Ch-'0');
                    
            if(In.peek()<=' 'break;
                }
                
            return In;
            }

            ostream 
            &operator<<(ostream &Out,const BigInt &V){
                
            int i;
                Out
            <<(V.Len==0 ? 0:V[V.Len-1]);
                
            for(i=V.Len-2;i>=0;i--for(int j=Base/10;j>0;j/=10) Out<<V[i]/j%10;
                
            return Out;
            }


            int inn, ink ;

            const BigInt Bint( 1 ) ;
            BigInt 
            out0 )  ;
            BigInt a( 
            0 ) ;
            BigInt bint[
            2000] ;

            void process()
            {
                bint[
            1= Bint * ink ;
                bint[
            2= Bint * ( (ink-1)*(ink) ) ;
                bint[
            3= Bint * ( (ink-1)*((ink-1)+(ink-1)*ink) ) ;

                
            forint i=4; i<=inn; i++ )
                {
                    bint[i] 
            = ( bint[i-2+ bint[i-1] )*(ink-1) ;
                }
            }


            void output()
            {
                cout 
            << bint[inn] << endl ;
            }


            int main()
            {
                
            while( cin >> inn >> ink )
                {
                    
            //input() ;

                    process() ;

                    output() ;
                }

                
            return 0 ;

            }
            亚洲精品无码久久久影院相关影片| 青青草国产成人久久91网| 日韩电影久久久被窝网| 2021国内久久精品| 日本久久久久亚洲中字幕| 久久精品夜夜夜夜夜久久| 热99re久久国超精品首页| 日韩精品无码久久一区二区三| 久久久久99这里有精品10| 999久久久免费精品国产| 国产综合免费精品久久久| 国产免费久久精品99re丫y| 狠狠色噜噜狠狠狠狠狠色综合久久| 91秦先生久久久久久久| 99久久无色码中文字幕人妻| 精品久久久久久国产91| 久久夜色精品国产亚洲| 99久久久久| 国产美女久久精品香蕉69| 久久久91人妻无码精品蜜桃HD| 色88久久久久高潮综合影院| 国产亚州精品女人久久久久久 | 久久狠狠爱亚洲综合影院| 精品国产乱码久久久久久1区2区| 久久久这里有精品中文字幕| 人妻丰满AV无码久久不卡| 伊人精品久久久久7777| 一本大道加勒比久久综合| 乱亲女H秽乱长久久久| 久久国产精品无| 人妻少妇精品久久| 激情综合色综合久久综合| 天天久久狠狠色综合| 99国产精品久久| 99久久国产综合精品麻豆| 久久精品夜夜夜夜夜久久| 亚洲AV乱码久久精品蜜桃| 热99RE久久精品这里都是精品免费 | 久久亚洲国产成人精品性色| 中文字幕无码免费久久| 伊人久久综合无码成人网|