He needs help !
查看原帖
He needs help !
1672765
forty_sixty楼主2025/7/21 14:42
#include<bits/stdc++.h>
using namespace std ;
int a[5010] , b[5010] , c[5010] ;
string x , y ;
int main() {
    cin >> x >> y ;
    int len_x = x.length() , len_y = y.length() ;
    for ( int i = len_x - 1 ; i >= 0 ; i -- )
        a[len_x - i] = x[i] - '0' ;
    for ( int i = len_y - 1 ; i >= 0 ; i -- )
        b[len_y - i]  = y[i] - '0' ;
    for ( int i = 1 ; i <= len_x ; i ++ )
        for( int j = 1 ; j <= len_y ; j ++ )
            a[i + j - 1] += a[i] * b[j] ;
    int len = len_x + len_y ;
    for ( int i = 1 ; i <= len ; i ++ ){
            c[i + 1] += c[i] / 10 ;
            c[i] %= 10 ;
    }
    for( ; !c[len] ; )
        len -- ;
    for ( int i = max(1 , len) ; i >= 1 ; i--)
        cout << c[i] ;
    return 0 ;
}

Help me , please.

2025/7/21 14:42
加载中...