【C++心路歷程11】1182火柴棒等式,打表!
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[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 main()
{
int n;
scanf("%d",&n);
cout<<a[n];
return 0;
}
/*#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[10]={6,2,5,5,4,5,6,3,7,6};
char b[10];
int gun(int x)
{
int c[10];
int ans=0,k=0;
if(x==0) return 6;
while(x>0)
{
c[k]=x%10;
x=x/10;
k++;
}
for(int i=0;i<k;i++)
{
ans+=a[c[i]];
}
memset(c,0,sizeof(c));
k=0;
return ans;
}
int main()
{
freopen("out.txt","w",stdout);
int cnt=0,n;
for(int i=1;i<=24;i++)
{
for(int A=0;A<=1112;A++)
for(int B=0;B<=1112;B++)
{
int C=A+B;
if(gun(A)+gun(B)+gun(C)+4==i)
cnt++;
}
printf("%d,",cnt);
cnt=0;
}
return 0;
}
*/