You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
911 B

#include<bits/stdc++.h>
using namespace std;
int Fun(int n)
{
//用数组列出0-9没一个数所需要的火柴棍数
int arr[10] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int ret = 0;
//判断n是不是两位数或更高位数
while (n / 10 != 0){
//将个位数所需要的火柴棍数相加
ret += arr[n % 10];
//更新n的个位数
n /= 10;
}
//最后加上此时n需要的火柴棍数(n是一位数)
ret += arr[n];
return ret;
}
int main()
{
int a, b, c, m, num = 0;
//printf("请输入火柴棍的个数\n");
scanf("%d", &m);
//枚举a和b
for (a = 0; a <= 1111; a++){
for (b = 0; b <= 1111; b++){
c = a + b;
//判读是否符合条件
if (Fun(a) + Fun(b) + Fun(c) == m - 4){
//printf("%d + %d = %d\n", a, b, c);
//计算所有可能的个数
num++;
}
}
}
//printf("一共可以拼出%d个不同等式\n", num);
//system("pause");
cout<<num;
return 0;
}