• <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 閱讀(194) 評論(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 ;

            }
            免费一级欧美大片久久网| 久久福利资源国产精品999| 久久国产乱子精品免费女| 久久国产精品国语对白| 香蕉久久夜色精品国产2020| 中文字幕乱码久久午夜| 色综合久久88色综合天天| 久久久久久久久久久精品尤物| 久久99国产精品一区二区| 香蕉久久夜色精品国产尤物| 久久免费视频网站| 麻豆av久久av盛宴av| 久久精品中文字幕有码| 91精品国产高清91久久久久久| 欧美亚洲日本久久精品| 国内精品久久久久久久影视麻豆 | 亚洲国产成人久久综合碰| 久久精品黄AA片一区二区三区| 国产99久久久国产精品~~牛 | 国产精品久久久福利| 亚洲AV无码1区2区久久| 国产精品久久久久久久久久影院| 一本大道加勒比久久综合| 久久久久久午夜成人影院| 久久精品国产亚洲αv忘忧草| 久久电影网| 四虎久久影院| 亚洲国产成人精品91久久久| 久久免费99精品国产自在现线| 久久国产精品99精品国产987| 久久香综合精品久久伊人| 亚洲精品乱码久久久久久蜜桃图片 | 香港aa三级久久三级| 亚洲国产成人久久综合一| jizzjizz国产精品久久| 国内精品久久人妻互换| 国产婷婷成人久久Av免费高清| 久久精品国产网红主播| 色综合久久天天综合| 久久精品国产亚洲AV不卡| 久久久久噜噜噜亚洲熟女综合|