#53666: 破防 80%


honzhe05@gmail.com (洪哲)

學校 : 國立中興大學附屬高級中學
編號 : 307284
來源 : [125.227.205.171]
最後登入時間 :
2025-08-24 09:47:52

#include <bits/stdc++.h>
using namespace std;
 
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
 
int n;
long long maxone = 0;
cin >> n;
vector<char> v(n);
for (int i=0; i<n; i++) cin >> v[i];
 
do {
string s, s1;
for (int i=0, j=n-1; i<=j; i++, j--) {
if (i == j) s1 += v[i];
  else s += v[i], s1 += v[j];
}
reverse(s1.begin(), s1.end());
if (s[0] != '0' && s1[0] != '0')
maxone = max(stoll(s) * stoll(s1), maxone);
 
} while (next_permutation(v.begin(), v.end()));
 
cout << maxone;
}