题意分析
暴力枚举
代码总览
#include<bits/stdc++.h>
using namespace std;
const int nmax = 1000;
int cnt[] = {6,2,5,5,4,5,6,3,7,6};
int n;
int get(int x){
if(x == 0) return 6;
int tot = 0;
while(x){
int t = x % 10;
tot += cnt[t];
x /= 10;
}
return tot;
}
int main(){
while(scanf("%d",&n)!=EOF){
n-=4;
int ans = 0;
for(int i = 0;i<nmax;++i){
for(int j = 0;j<nmax;++j){
if(get(i) + get(j) + get(i+j) == n){
ans++;
}
}
}
printf("%d\n",ans);
}
return 0;
}
本文探讨了一个关于数字组合的问题,通过定义特定的数字映射规则,使用暴力枚举的方法来找出所有可能的数字组合,使得这些组合满足给定条件。代码中详细展示了如何计算每个数字的段数,并通过双重循环遍历所有可能的组合。
768

被折叠的 条评论
为什么被折叠?



