#include <bits/stdc++.h>
using
namespace
std;
int
bit_score(
int
N)
{
int
maxi = 0, mini = 11;
int
score;
for
(
int
i = 0; i < 3; i++) {
maxi = max(maxi, N % 10);
mini = min(mini, N % 10);
N /= 10;
if
(N == 0)
break
;
}
score = maxi * 11 + mini * 7;
score = score % 100;
return
score;
}
int
findPairs(
int
arr[],
int
N,
int
a,
int
b)
{
for
(
int
i = 0; i < N; i++) {
arr[i] = bit_score(arr[i]);
}
int
pairs = 0;
int
mp[10][2];
memset
(mp, 0,
sizeof
(mp));
for
(
int
i = 0; i < N; i++)
mp[arr[i] / 10][i % 2]++;
for
(
int
i = 0; i < 10; i++) {
if
(mp[i][1] >= 3 || mp[i][0] >= 3)
pairs += 2;
else
if
(mp[i][1] == 2 && mp[i][0] == 2)
pairs += 2;
else
if
(mp[i][1] == 2 || mp[i][0] == 2)
pairs += 1;
}
return
pairs;
}
int
main()
{
int
arr[] = { 234, 567, 321, 345,
123, 110, 767, 111 };
int
N =
sizeof
(arr) /
sizeof
(arr[0]);
int
a = 11, b = 7;
cout << findPairs(arr, N, a, b);
return
0;
}
0 comments:
Post a Comment