0分求调

P1303 A*B Problem

___njr___ @ 2023-02-23 13:47:11


#include<bits/stdc++.h>
using namespace std;
//#define frein(a)  freopen(a,"r",stdin)
//#define freout(a) freopen(a,"w",stdout)
#define inline
class BigInt {
        /*
        * 倒序储存
        */
        int a[5010];
        int len = 0;
    public:
        inline void operator++() {
            int i = 0 ;
            while(a[i]==9) {
                a[i++]=0;
            }
            ++a[i];
        }
        inline bool operator==(BigInt other) {
            if(len != other.len) return false;
            for(int i= 0 ; i<len; ++i)if(a[i]^other.a[i])return false;
            return true;
        }
        inline void operator=(BigInt other) {
            len = other.len;
            memset(a,0,sizeof(a));
            for(int i = 0 ; i<len; ++i)a[i]=other.a[i];
            return;
        }
        inline void Pals_zero() {
            for(int i = len ; i>0 ; ++i)a[i] = a[i-1];
            a[0] = 0;
            ++len;
        }
        inline BigInt operator + (BigInt other) {
            BigInt ret = (*this);
            int tmp=0;//进位
            int Len = max(len , other.len);
            for(int i = 0 ; i< Len ; ++i) {
                ret.a[i] += other.a[i]+tmp;
                tmp = ret.a[i] / 10;
                ret.a[i] %= 10;
            }
            if(tmp)ret.a[Len++] = tmp;
            ret.len = Len ;
            return ret;
        }
        inline void chulin() {
            while(!a[--len]);
            ++len;
        }
//      inline BigInt operator-(BigInt other) {
//          BigInt ans;
//          int Len = max(len , other.len);
//          for(int i = 0 ; i < Len;++i)ans.a[i] = a[i]-other.a[i];
//          for(int i = 0 ; i < Len;++i)if(ans.a[i]<0){
//              ans.a[i]+=10;
//              --ans.a[i+1];
//          }
//          ans.len  =Len;
//          ans.Out() ;
//          ans.chulin();
//      }
        inline BigInt operator *  (BigInt other) {
            int tmp = 0 ;
            BigInt ans;
            int Len = len+other.len-1;
            for(int i = 0 ; i<len; ++i)for(int j = 0 ; j <other.len; ++j)ans.a[i+j]+=a[i]*other.a[j];
            for(int i = 0; i <Len; ++i)while(a[i]>=10) {
                    a[i]-=10;
                    ++a[i+1];
                }
//          if(a[Len-1]>=10) {
//              a[Len]=a[Len-1]/10;
//              a[Len-1]%=10;
//              ++Len;
//          }
            if(ans.a[Len])++Len;
            ans.len = Len;
            ans.chulin() ;
            return ans;
        }
        inline void Out() {
            BigInt other = *this;
            if(other.len = 0)putchar(48);
            else while(other.len)putchar(48+other.a[--other.len]);
        }
        inline void in() {
            string s;
            cin>>s;
            for(int i = 0 ; i <s.size(); ++i)a[i] = s[s.size()-i-1]-48;
            len = s.size();
        }
        inline void operator = (unsigned long long other) {
            BigInt ret;
            while(other) {
                ret.a[ret.len++] = other%10;
                other/=10;
            }
            (*this) = ret;
        }
};
int main() {
    BigInt a , b;
//  a = 999;
//  b=888;
    a.in();
    b.in();
    BigInt c = a*b;
    c.Out();
}

by 2011Andy @ 2023-02-23 13:48:41

6


by fkcufk @ 2023-03-19 09:15:00

@liuhaodong2021

print(int(input())*int(input()))

by ___njr___ @ 2023-03-19 14:39:54

@BiiiiigApple

a = int(input())
print(a*input())

by fkcufk @ 2023-03-19 14:45:22

@liuhaodong2021 也可以


|