提交时间:2024-01-23 16:20:21

运行 ID: 125025

#include<bits/stdc++.h> using namespace std; int f[10]={6,2,5,5,4,5,6,3,7,6}; // 数字 0~9 对应的火柴棍数 int tot(int x) // 计算每个数由多少根火柴棍组成 { int total=0; do{ total+=f[x%10]; x/=10; }while(x); return total; } int main() { int n; cin>>n; n=n-4; // 减去 '+' 和 '=' 所需的火柴棍数 int a,b,cnt=0; for(a=0;a<1000;a++){ for(b=0;b<1000;b++){ if(tot(a)+tot(b)+tot(a+b)==n) cnt++; } } cout<<cnt<<endl; return 0; }