提交时间:2023-10-10 13:57:26
运行 ID: 106269
#include <bits/stdc++.h> #define int long long using namespace std; int c[114514191]; signed main() { string a,b,a_,b_; int n; cin >> a_ >> b_; for(int i = a_.length()-1; i >= 0; i--) { a += a_[i]; } for(int i = b_.length()-1; i >= 0; i--) { b += b_[i]; } if(a_.length()>b_.length()) { for(int i = 1; i <= a_.length()-b_.length(); i++)b+='0'; } if(b_.length()>a_.length()) { for(int i = 1; i <= b_.length()-a_.length(); i++)a+='0'; } n = a.length(); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { c[i+j]+=(b[i]-'0')*(a[j]-'0'); c[i+j+1]+=c[i+j]/10; c[i+j]%=10; } } if(c[n]) { n++; } bool flag = false; for(int i = 2*n; i >= 0; i--) { if(c[i]&&!flag) { flag = true; } if(flag) { cout << c[i]; } } if(!flag) { cout << 0; } return 0; }