P1149 [NOIP2008 提高组] 火柴棒等式

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
        int a[2001]={6},b,c[2000]={6,2,5,5,4,5,6,3,7,6},s=0,i,j;
        scanf("%d",&b);
        for(i=10;i<=2000;i++)
        {
            c[i]=c[i/10]+c[i%10];
        }
       
        for(i=0;i<=1000;i++)//i ->+ 
        {
                for(j=0;j<=1000;j++)
                if(c[i]+c[j]+c[i+j]+4==b)//if i==j repeat 1
                {
                    s++;
                    //cout<<i<<"+"<<j<<endl;
                   // if(i==j) s--;
                }
        }
        printf("%d",s);
        return 0;
}
View Code
 

 

 
posted @ 2023-07-13 08:59  JMXZ  阅读(5)  评论(0)    收藏  举报