P1149 火柴棒等式
//Pro:NOIP2008 T2 P1149 火柴棒等式 #include<iostream> #include<cstring> #include<cmath> #include<cstdio> #include<algorithm> using namespace std; const int N=50; const int stick[N]={6,2,5,5,4,5,6,3,7,6}; int n; int work(int x) { int res=0; do { res+=stick[x%10]; x/=10; }while(x); return res; } int ans; int main() { scanf("%d",&n); n-=4; for(int i=0;i<=1000;++i) for(int j=0;j<=1000;++j) { if(work(i)+work(j)+work(i+j)==n) ++ans; } printf("%d",ans); return 0; }