Title Description
N matchsticks you, you can spell the number shaped as " A = B + C A + B = C" of the equation? Equation A, B, C is an integer with a match stick spell (if the number of non-zero, then the most significant bit is not 0). Fight of a matchstick 0 - spelling as shown in Figure 9:
note:
-
Plus their needs and equal sign two matchsticks
-
If A ≠ B , then A + B = C and B + A = C as different equations ( A , B , C > = 0)
-
n matchsticks must all spend
Input Format
An integer n-(n-<= 24) .
Output Format
An integer number of different equations could spell.
Sample input and output
Entry
14
Export
2
Entry
18
Export
9
Description / Tips
Sample 1 O [explain]
Equation 2 is 0 + 1 = 1 and 1 + 0 = 1.
Sample 2 O [explain]
. 9 equations to:
0+4=4
0+11=11
1+10=11
2+2=4
2+7=9
4+0=4
7+2=9
10+1=11
11+0=11
思路:打表(第一次尝试,注释代码用来生成表)
代码:
#include<cstdio>
//int cost[10000]={6,2,5,5,4,5,6,3,7,6};
//int main(){
// int sum=0;
// for(int i=10;i<10000;i++){
// sum=0;
// int k=i;
// while(k){
// sum+=cost[k%10];
// k/=10;
// }
// cost[i]=sum;
// }
// for(int k=0;k<=24;k++){
// sum=0;
// for(int i=0;i<5000;i++){
// for(int j=0;j<5000;j++){
// if(cost[i]+cost[j]+cost[i+j]==k-4){
// sum++;
// }
// }
// }
// printf("%d ",sum);
// }
//}
int main(){
int num[25]={0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,8,9,6,9,29,39,38,65,88,128};
int n;scanf("%d",&n);
printf("%d",num[n]);
}