Untitled

 avatar
unknown
c_cpp
2 years ago
829 B
5
Indexable
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;

  vector<string> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  int max_product = 0;
  for (int i = 0; i < n; i++) {
    int value1 = 0;
    for (char c : arr[i]) {
      if (isdigit(c)) {
        value1 *= 10;
        value1 += c - '0';
      }
    }
    if (value1 == 0) {
      value1 = arr[i].length();
    }

    for (int j = i + 1; j < n; j++) {
      int value2 = 0;
      for (char c : arr[j]) {
        if (isdigit(c)) {
          value2 *= 10;
          value2 += c - '0';
        }
      }
      if (value2 == 0) {
        value2 = arr[j].length();
      }

      max_product = max(max_product, value1 * value2);
    }
  }

  cout << max_product << endl;

  return 0;
}
Editor is loading...