1 条题解

  • 1

    #include<iostream>
    #include<iomanip>
    #include<cmath>
    #include<bits/stdc++.h>
    #include<cstdio>
    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;
    }

  • 1

信息

ID
1348
难度
2
分类
搜索 点击显示
标签
递交数
28
已通过
20
通过率
71%
上传者