File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < vector>
3
+ #include < algorithm>
4
+ #define MAX 1000
5
+ using namespace std ;
6
+
7
+ int cnt[MAX];
8
+ int N;
9
+
10
+ void func () {
11
+ vector<int > v;
12
+ for (int i = 1 ; i < MAX; i++) {
13
+ cnt[i] = min (cnt[i], 2 );
14
+ while (cnt[i]--) v.push_back (i);
15
+ }
16
+
17
+ int ret = 0 ;
18
+ for (int i = 0 ; i < v.size (); i++) {
19
+ for (int j = i + 1 ; j < v.size (); j++) {
20
+ int tmp = v[i] * v[j];
21
+ int sum = 0 ;
22
+ while (tmp) {
23
+ sum += (tmp % 10 );
24
+ tmp /= 10 ;
25
+ }
26
+ ret = max (ret, sum);
27
+ }
28
+ }
29
+ cout << ret << ' \n ' ;
30
+ }
31
+
32
+ void input () {
33
+ int x;
34
+ cin >> N;
35
+ for (int i = 0 ; i < N; i++) {
36
+ cin >> x;
37
+ cnt[x]++;
38
+ }
39
+ }
40
+
41
+ int main () {
42
+ cin.tie (NULL ); cout.tie (NULL );
43
+ ios::sync_with_stdio (false );
44
+
45
+ input ();
46
+ func ();
47
+
48
+ return 0 ;
49
+ }
You can’t perform that action at this time.
0 commit comments