Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
125025 | YYYY | 火柴棒等式 | C++ | 通过 | 100 | 13 MS | 252 KB | 515 | 2024-01-23 16:20:21 |
#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; }