Untitled
unknown
c_cpp
2 years ago
895 B
6
Indexable
#include <iostream> #include <string> #include <algorithm> using namespace std; int get_value(string str) { if (any_of(str.begin(), str.end(), ::isdigit)) { int value = 0; for (char c : str) { if (isdigit(c)) { value *= 10; value += c - '0'; } } return value; } else { return str.length(); } } int find_max_product(vector<string> arr) { int max_product = 0; for (int i = 0; i < arr.size(); i++) { for (int j = i + 1; j < arr.size(); j++) { int product = get_value(arr[i]) * get_value(arr[j]); max_product = max(max_product, product); } } return max_product; } int main() { int n; cin >> n; vector<string> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } int max_product = find_max_product(arr); cout << max_product << endl; return 0; }
Editor is loading...