https://www.acmicpc.net/problem/1225
'두 수는 모두 10,000자리를 넘지 않는 음이 아닌 정수'라는 점에 주목하면 됩니다.
10,000자리를 넘지 않기에 최대 10,000^2만큼의 연산을 한다고 보면 됩니다.
#include <iostream>
using namespace std;
string A, B;
long long result;
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> A >> B;
for (const char &c1 : A)
{
long long n1 = c1 - '0';
for (const char &c2 : B)
{
long long n2 = c2 - '0';
result += n1 * n2;
}
}
cout << result;
return 0;
}
2중 for문으로 A와 B의 모든 조합을 곱해주면 됩니다.