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

            }
            久久国产福利免费| 中文国产成人精品久久不卡 | 久久精品国产精品亚洲精品| 国产精品久久久香蕉| 久久久久波多野结衣高潮| 国产成人精品免费久久久久| 国内精品伊人久久久久影院对白| 久久九九久精品国产| 久久久无码人妻精品无码| 久久夜色精品国产亚洲| 国内精品久久国产| 88久久精品无码一区二区毛片| 香蕉aa三级久久毛片| 久久九九有精品国产23百花影院| 久久天天躁狠狠躁夜夜2020| 久久久久久久久无码精品亚洲日韩 | 亚洲国产成人久久综合碰| 久久丫精品国产亚洲av| 日本国产精品久久| 精品一区二区久久久久久久网站| 久久久久国产精品麻豆AR影院| 国产精品99久久99久久久| 久久久久久精品成人免费图片| 国产亚州精品女人久久久久久| 久久久亚洲欧洲日产国码二区| 老司机午夜网站国内精品久久久久久久久 | 国产精品久久久久aaaa| 成人久久免费网站| 中文字幕人妻色偷偷久久 | 一本色道久久88综合日韩精品 | 久久av高潮av无码av喷吹| 久久99精品国产99久久| 无码精品久久久久久人妻中字| 久久亚洲精品国产亚洲老地址| 久久国产视屏| 久久高清一级毛片| 91久久精品无码一区二区毛片| 99久久久国产精品免费无卡顿| 亚洲AV日韩精品久久久久久久| 99精品国产综合久久久久五月天| 久久综合五月丁香久久激情|