Submission #1094547

#TimeUsernameProblemLanguageResultExecution timeMemory
1094547raphaelpMultiply (CEOI17_mul)C++14
100 / 100
868 ms1288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...