# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1094547 |
2024-09-29T21:43:12 Z |
raphaelp |
Multiply (CEOI17_mul) |
C++14 |
|
868 ms |
1288 KB |
#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 |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
12 ms |
544 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
12 ms |
544 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
327 ms |
860 KB |
Output is correct |
17 |
Correct |
868 ms |
1288 KB |
Output is correct |
18 |
Correct |
85 ms |
992 KB |
Output is correct |
19 |
Correct |
769 ms |
1228 KB |
Output is correct |
20 |
Correct |
2 ms |
860 KB |
Output is correct |