题解
2025-09-26 20:02:20
发布于:广东
1阅读
0回复
0点赞
#include <iostream>
using namespace std;
int match[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int numMatches[2000]; // 预处理0-1999的数字所需火柴数
int main() {
int n;
cin >> n;
if (n < 13) {
cout << 0 << endl;
return 0;
}
// 预处理所有数字的火柴数
for (int i = 0; i < 2000; i++) {
int num = i;
if (num == 0) {
numMatches[i] = match[0];
continue;
}
int total = 0;
while (num > 0) {
total += match[num % 10];
num /= 10;
}
numMatches[i] = total;
}
int available = n - 4;
int result = 0;
// 枚举A和B
for (int a = 0; a <= 999; a++) {
for (int b = 0; b <= 999; b++) {
int c = a + b;
if (c >= 2000) continue;
if (numMatches[a] + numMatches[b] + numMatches[c] == available) {
result++;
}
}
}
cout << result << endl;
return 0;
}
这里空空如也






有帮助,赞一个