提交时间:2023-10-06 18:06:59
运行 ID: 105466
#include<bits/stdc++.h> using namespace std; int a[5005] = {0},b[5005] = {0},c[5005] = {0}; int main(){ string x,y; cin>>x>>y; int xs = x.size(); int ys = y.size(); for (int i = xs - 1;i >= 0;i--){ a[i] = x[xs - i - 1] - 48; } for (int i = ys - 1;i >= 0;i--){ b[i] = y[ys - i - 1] - 48; } int o = 0,maxl = 4514; for (int i = 0;i < maxl;i++){ for (int j = 0;j < maxl;j++){ if (i + j < maxl){ c[i + j] += a[i] * b[j]; if (c[i + j] >= 10){ c[i + j + 1] += c[i + j] / 10; c[i + j] %= 10; } } } } maxl--; while (c[maxl] == 0 && maxl >= 0){ maxl--; } if (maxl == -1){ cout<<0<<endl; return 0; } for (int i = maxl;i >= 0;i--){ cout<<c[i]; } return 0; }