CCPC 2020 吉林

## A

#include <bits/stdc++.h>
using namespace std;
int a[] = {1, 6, 28, 88, 198, 328, 648};
map<int, int> fr;
bool chk(int sta, int n) {
int cost = 0;
for (int i = 0; i < 7; ++i) {
if ((sta >> i) & 1) {
cost += a[i];
}
}
return cost <= n;
}
pair<int, int> solve(int sta, int n) {
int ans = 0;
for (int i = 0; i < 7; ++i) {
if ((sta >> i) & 1) {
ans += fr[a[i]], n -= a[i];
}
}
return make_pair(ans, n);
}
int main() {
fr[1] = 8;
fr[6] = 18;
fr[28] = 28;
fr[88] = 58;
fr[198] = 128;
fr[328] = 198;
fr[648] = 388;
int n;
// cout << solve(31, 328).first + solve(31, 328).second * 10 << endl;
while (cin >> n) {
pair<int, int> ans = make_pair(0, n);
int sta = 0, maxsta = 1 << 7;
for (int i = 0; i < maxsta; ++i) {
if (chk(i, n)) {
pair<int, int> now = solve(i, n);
if (ans.first <= now.first) ans = now;
}
}
printf("%d\n", ans.first + n * 10);
}
return 0;
}

2022-12-30 19:02

01-13 18:31

01-12 12:42

2022-12-14 18:10

2022-12-22 16:33

2022-12-09 22:38

2022-12-23 17:45

2022-12-17 02:23