1 条题解

  • 0
    @ 2023-8-23 21:38:08
    #include
    using namespace std;
    int st[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};//st[i]:数字i的火柴棍数 
    int matchCt(int x)//求数字x由多少个火柴棍组成 
    {
    	int s = 0, a = x;
    	do
    	{
    		s += st[a%10];
    		a /= 10;
    	}while(a > 0);
    	return s;
    }
    int main()
    {
    	int n, ct = 0;//ct:加和为n的个数 
    	cin >> n;
    	for(int i = 0; i <= 1111; ++i)//考虑到1111+1=1112,已经用了21个火柴了,数字再大只能使用更多火柴 
    		for(int j = 0; j <= 1111; ++j)
    			if(matchCt(i) + matchCt(j) + matchCt(i+j) + 4 == n)//公式i加j等于i+j的总火柴棍数量 
    				ct++;
    	cout << ct;
    	return 0;
    }
    
    • 1

    信息

    ID
    150
    时间
    1000ms
    内存
    125MiB
    难度
    2
    标签
    递交数
    70
    已通过
    33
    上传者