提交时间:2024-08-20 14:42:46
运行 ID: 168914
#include<bits/stdc++.h> using namespace std; const int MaxN = 5001; int a[MaxN], b[MaxN], c[MaxN]; int main() { string A, B; cin >> A >> B; int La = A.length(); int Lb = B.length(); for (int i=La-1, j=1; i>=0; i--, j++) a[j] = A[i] - '0'; for (int i=Lb-1, j=1; i>=0; i--, j++) b[j] = B[i] - '0'; for (int i=1; i<=La; i++) for (int j=1; j<=Lb; j++) { c[i+j-1] += a[i]*b[j]; c[i+j] += c[i+j-1]/10; c[i+j-1]%=10; } int Lc=La+Lb; while (c[Lc]==0 && Lc>1) Lc--; for (int i=max(1,Lc); i>=1; i--) cout<<c[i]; return 0; }