This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
//数字0-9需要的火柴个数,这个字典妙啊~,成为解决火柴棍难题的关键~
int a[N] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
// 根据数字获取对应的火柴棍数量
int getNum(int n) {
if (n == 0) return a[0];
int s = 0;
while (n) {
int m = n % 10;
s += a[m];
n /= 10;
}
return s;
int n, cnt;
int main() {
//等号2个,加号2个
//给n根火柴棍,要求全部用上
//n的极限值是24,那么去掉4根就剩下20根,就是3个数加在一起需要20根
cin >> n;
for (int i = 0; i <= 999; i++)
for (int j = 0; j <= 999; j++)
if (getNum(i) + getNum(j) + getNum(i + j) == n - 4) cnt++;
cout << cnt << endl;
return 0;