1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #include <iostream> #include <algorithm> #include <cstring> using namespace std; int res=0; int st[10000]; int n; int m=0; int arr[4]={0};
int ls[10]={6,2,5,5,4,5,6,3,7,6}; int number(int x) { int count = 0; if (x == 0) return ls[0]; while (x > 0) { count += ls[x % 10]; x /= 10; } return count; }
void dfs(int x){ if(x>=3){ int A = arr[1]; int B = arr[2]; int C = A + B; if(number(A)+number(B)+number(C)+4==n){ ++res; } return; } for(int i=0;i<1000;i++){ arr[x]=i; dfs(x+1); arr[x]=0;
} }
int main(){ scanf("%d",&n); dfs(1); cout<<res<<endl; return 0; }
|