- 火柴棒等式
- 2015-08-03 08:43:00 @
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int a[10]={6,2,5,5,4,5,6,3,7,6};
int main()
{
int n,k=0;
scanf("%d",&n);
for(int i=0;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
if(a[i]+a[j]+a[i+j]+4==n&&i<=9&&j<=9&&i+j<=9)
{
if(i!=j)k+=2;
else k++;
}
else if(i<=9&&j<=9)
{
int y=i+j;
int x1,x2;
x1=y%10;
x2=y/10;
if(a[i]+a[j]+a[x1]+a[x2]+4==n)
{
if(i!=j)k+=2;
else k++;
}
}
else if(i<=9)
{
int y=i+j;
int x1,x2,y1,y2;
x1=y%10;
x2=y/10;
y1=j%10;
y2=j/10;
if(a[i]+a[y1]+a[y2]+a[x1]+a[x2]+4==n)
{
if(i!=j)k+=2;
else k++;
}
}
else if(j<=9)
{
int y=i+j;
int x1,x2,y1,y2;
x1=y%10;
x2=y/10;
y1=i%10;
y2=i/10;
if(a[j]+a[y1]+a[y2]+a[x1]+a[x2]+4==n)
{
if(i!=j)k+=2;
else k++;
}
}
else
{
int y=i+j;
int x1,x2,y1,y2,z1,z2;
x1=y%10;
x2=y/10;
y1=i%10;
y2=i/10;
z1=j%10;
z2=j/10;
if(a[z1]+a[z2]+a[y1]+a[y2]+a[x1]+a[x2]+4==n)
{
if(i!=j)k+=2;
else k++;
}
}
}
}
printf("%d\n",k);
return 0;
}
1 条评论
-
xjwwd LV 8 @ 2015-08-03 09:11:27
rqnoj上的这道题zgx发了题解
- 1