This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<int> A(N), B(M), ans(N + M + 1);
string S1, S2;
cin >> S1 >> S2;
for (int i = 0; i < N; i++)
{
A[i] = S1[N - i - 1] - '0';
}
for (int i = 0; i < M; i++)
{
B[i] = S2[M - i - 1] - '0';
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
ans[i + j] += A[i] * B[j];
}
}
for (int i = 0; i < N + M; i++)
{
ans[i + 1] += ans[i] / 10;
ans[i] %= 10;
}
int buff = N + M;
while (buff > 0 && ans[buff] == 0)
buff--;
while (buff >= 0)
{
cout << ans[buff--];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |