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

            }
            久久国产精品久久国产精品| 亚洲国产成人精品久久久国产成人一区二区三区综| 一本大道久久东京热无码AV| 伊人久久亚洲综合影院| 亚洲中文字幕久久精品无码APP | 国内精品久久久久久野外| www久久久天天com| 久久人搡人人玩人妻精品首页| 亚洲国产另类久久久精品 | 久久久精品波多野结衣| 久久天天躁狠狠躁夜夜2020一| 久久婷婷五月综合国产尤物app| 久久精品国产一区| 亚洲国产另类久久久精品黑人 | 亚洲AV日韩精品久久久久久久| 久久久国产精品网站| 亚洲综合伊人久久综合| 91久久精品国产91性色也| 亚洲va国产va天堂va久久| 久久久精品久久久久特色影视 | 亚洲精品综合久久| 国产亚洲成人久久| 伊人久久大香线蕉影院95| 久久99热只有频精品8| 国色天香久久久久久久小说| 久久久久这里只有精品| 久久久久四虎国产精品| www性久久久com| 国内精品久久久久影院免费| 91精品国产91久久综合| 久久精品国产亚洲av影院| 久久久女人与动物群交毛片| 色婷婷综合久久久久中文| 国内精品综合久久久40p| 99久久夜色精品国产网站| 奇米影视7777久久精品人人爽| 九九精品久久久久久噜噜| 性做久久久久久免费观看| 伊人久久大香线蕉综合网站| 一级A毛片免费观看久久精品| 尹人香蕉久久99天天拍|