• <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
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            P2389——高精度乘法

            Posted on 2008-09-03 19:14 Hero 閱讀(176) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
              1 //2389 Accepted 452K 0MS G++ 2363B PKU
              2 
              3 //高精度乘法
              4 #include <iostream>
              5 using namespace std;
              6 
              7 const int Base=1000000000;
              8 const int Dlen=300;
              9 typedef long long llong;
             10 struct BigInt{
             11     int Len;
             12     int Data[Dlen];
             13     BigInt():Len(0){}
             14     BigInt(const BigInt &num):Len(num.Len){memcpy(Data,num.Data,Len*sizeof*Data);}
             15     BigInt(int num):Len(0){for(;num>0;num/=Base) Data[Len++]=num%Base;}
             16     BigInt &operator=(const BigInt &num){Len=num.Len;memcpy(Data,num.Data,Len*sizeof*Data);return *this;}
             17     int &operator[](int Index){return Data[Index];}
             18     int operator[](int Index)const{return Data[Index];}
             19 };
             20 int compare(const BigInt &A,const BigInt &B){
             21     if(A.Len!=B.Len) return A.Len>B.Len ? 1:-1;
             22     int i;
             23     for(i=A.Len-1;i>=0 && A[i]==B[i];i--);
             24     if(i<0)return 0;
             25     return A[i]>B[i] ? 1:-1;
             26 }
             27 BigInt operator+(const BigInt &A,const BigInt &B){
             28     int i,Carry(0);
             29     BigInt R;
             30     for(i=0;i<A.Len||i<B.Len||Carry>0;i++){
             31         if(i<A.Len) Carry+=A[i];
             32         if(i<B.Len) Carry+=B[i];;
             33         R[i]=Carry%Base;
             34         Carry/=Base;
             35     }
             36     R.Len=i;
             37     return R;
             38 }
             39 BigInt operator-(const BigInt &A,const BigInt &B){
             40     int i,Carry(0);
             41     BigInt R;
             42     R.Len=A.Len;
             43     for(i=0;i<R.Len;i++){
             44         R[i]=A[i]-Carry;
             45         if(i<B.Len) R[i]-=B[i];
             46         if(R[i]<0) Carry=1,R[i]+=Base;
             47         else Carry=0;
             48     }
             49     while(R.Len>0&&R[R.Len-1]==0) R.Len--;
             50     return R;
             51 }
             52 BigInt operator*(const BigInt &A,const int &B){
             53     int i;
             54     llong Carry(0);
             55     BigInt R;
             56     for(i=0;i<A.Len||Carry>0;i++){
             57         if(i<A.Len) Carry+=llong(A[i])*B;
             58         R[i]=Carry%Base;
             59         Carry/=Base;
             60     }
             61     R.Len=i;
             62     return R;
             63 }
             64 istream &operator>>(istream &In,BigInt &num){
             65     char Ch;
             66     for(num=0;In>>Ch;){
             67         num=num*10+(Ch-'0');
             68         if(In.peek()<=' 'break;
             69     }
             70     return In;
             71 }
             72 ostream &operator<<(ostream &Out,const BigInt &num){
             73     int i;
             74     Out<<(num.Len==0 ? 0:num[num.Len-1]);
             75     for(i=num.Len-2;i>=0;i--for(int j=Base/10;j>0;j/=10) Out<<num[i]/j%10;
             76     return Out;
             77 }
             78 
             79 BigInt Bint0(0) ;
             80 BigInt Bint1(1) ;
             81 
             82 BigInt ina, inb, inc ;
             83 BigInt out ;
             84 
             85 int main()
             86 {
             87     while( cin >> ina >> inb )
             88     {
             89         inc = Bint1 ; out = Bint0 ;
             90         forint i=0; i<inb.Len; i++ )
             91         {
             92             inc = ina * inb.Data[i] ;
             93             forint j=0; j<i; j++ ) inc = inc * Base ;
             94             out = out + inc ;
             95         }
             96         
             97 
             98         cout << out << endl ;
             99     }
            100 
            101     return 0 ;
            102 }
            亚洲性久久久影院| 久久大香萑太香蕉av| 婷婷久久久亚洲欧洲日产国码AV| 深夜久久AAAAA级毛片免费看| 综合久久一区二区三区| 久久久久亚洲精品无码蜜桃| 久久99精品久久只有精品| 高清免费久久午夜精品| 久久精品成人免费观看97| 久久久久久久精品妇女99| 国内精品九九久久久精品| 久久黄色视频| 国产精品久久久久久久久免费| 青春久久| 丁香久久婷婷国产午夜视频| 亚洲国产成人久久笫一页| 精品国产福利久久久| 亚洲国产成人精品女人久久久| 久久综合狠狠综合久久综合88| 日日狠狠久久偷偷色综合96蜜桃| 国产成人久久AV免费| 亚洲精品国产自在久久| 一级做a爰片久久毛片人呢| 女人高潮久久久叫人喷水| 亚洲综合日韩久久成人AV| 99久久99久久精品国产片果冻| 国产2021久久精品| 中文成人无码精品久久久不卡 | 中文字幕乱码人妻无码久久| 久久久久99精品成人片三人毛片| 久久久精品人妻一区二区三区蜜桃| 久久久噜噜噜www成人网| 狠狠色丁香久久婷婷综合_中 | 69SEX久久精品国产麻豆| 伊人久久免费视频| 性做久久久久久久久老女人| 国产精品久久久久久福利漫画| 欧美与黑人午夜性猛交久久久| 热久久国产欧美一区二区精品| 久久精品国产精品亚洲精品 | 久久国产成人午夜aⅴ影院|