题目:http://www.luogu.org/problem/show?pid=1149#
分析:
不知道怎么做= -,于是暴力枚举,发现n^2最大只能1000,于是就设这个边界,于是就过了= -
代码:
#include <cstdio>
#include <algorithm>
using namespace std;
const int p[15]={6,2,5,5,4,5,6,3,7,6};
const long long int inf=1000;
int n,ans;
void work()
{
long long int i,j;
int sum,tmp;
n-=4;
for(i=0;i<=inf;i++)
{
for(j=0;j<=inf;j++)
{
sum=0;
tmp=i;
if(i==0) sum+=p[0];
else while(tmp>0)
{
sum+=p[tmp%10];
tmp/=10;
}
tmp=j;
if(j==0) sum+=p[0];
else while(tmp>0)
{
sum+=p[tmp%10];
tmp/=10;
}
tmp=i+j;
if(tmp==0) sum+=p[0];
else while(tmp>0)
{
sum+=p[tmp%10];
tmp/=10;
}
if(sum==n) ans++;
}
}
printf("%d",ans);
return;
}
int main()
{
scanf("%d",&n);
work();
return 0;
}