19 lines
495 B
C++
19 lines
495 B
C++
|
#include <iostream>
|
||
|
#include <regex>
|
||
|
#include <string>
|
||
|
|
||
|
int main() {
|
||
|
std::string line;
|
||
|
std::regex r{"mul\\((\\d+),(\\d+)\\)"};
|
||
|
int result = 0;
|
||
|
while (std::getline(std::cin, line)) {
|
||
|
for (std::sregex_iterator iter{line.begin(), line.end(), r}, iter_end; iter != iter_end; iter++) {
|
||
|
const auto &match = *iter;
|
||
|
const auto op1 = std::stoi(match[1]), op2 = std::stoi(match[2]);
|
||
|
result += op1 * op2;
|
||
|
}
|
||
|
}
|
||
|
std::cout << result << std::endl;
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|