출처
- 2024 서강대학교 K512컵 A번
문제
풀이
#include <iostream>
#include <vector>
using namespace std;
void solve(void) {
int n, m; cin >> n >> m;
vector<int> a(n), b(m);
for (int i=0; i<n; i++) cin >> a[i];
for (int i=0; i<m; i++) cin >> b[i];
long long ans = 0;
for (int i=0; i<n; i++) ans += a[i];
for (int i=0; i<m; i++) {
if (b[i] == 0) continue;
ans *= b[i];
}
cout << ans;
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}