记录编号 |
365216 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[金陵中学2007] 吉祥数 |
最终得分 |
100 |
用户昵称 |
HeHe |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.003 s |
提交时间 |
2017-01-19 21:59:32 |
内存使用 |
0.32 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
using namespace std;
int biao[9][10]={{0,1,1,1,1,1,1,1,1,1},
{0,1,2,3,4,5,6,7,8,9},
{0,1,4,9,16,25,36,49,64,81},
{0,1,8,27,64,125,216,343,512,729},
{0,1,16,81,256,625,1296,2401,4096,6561},
{0,1,32,243,1024,3125,7776,16807,32768,59049},
{0,1,64,729,4096,15625,46656,117649,262144,531441},
{0,1,128,2187,16384,78125,279936,823543,2097152,4782969},
{0,1,256,6561,65536,390625,1679616,5764801,16777216,43046721}};
int n,tot,ha,sta;
bool exist[300];
int num[300],p[300],sum[300];
void Get_line()
{
int tmp;
while(scanf("%d",&tmp)==1)
{
num[tot]=tmp;
exist[tmp]=1;
sum[tmp]++;
tot++;
}
}
int doit(int a,int c)
{
if(a==0)return 0;
int res(0);
int s[5],len(0);
while(a)
{
s[len]=a%10;
a/=10;
len++;
}
for(int i(0);i<len;i++)
res+=biao[c][s[i]];
return res;
}
int main()
{
freopen("ghillie.in","r",stdin);
freopen("ghillie.out","w",stdout);
scanf("%d",&n);
n++;
Get_line();
for(int j=2;j<=n;j++)
{
sta=0;
for(int i(0);i<tot;i++)
{
if(exist[num[i]])
{
ha=doit(num[i],j);
if(ha<255)p[sta]=ha,sta++;
}
}
for(int i(0);i<sta;i++)
exist[p[i]]=0;
}
for(int i(0);i<255;i++)
{
if(exist[i])
while(sum[i])
cout<<i<<' ',sum[i]--;
}
return 0;
}