记录编号 |
69488 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[金陵中学2007] 吉祥数 |
最终得分 |
100 |
用户昵称 |
zjmfrank2012 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.002 s |
提交时间 |
2013-09-16 22:17:05 |
内存使用 |
0.31 MiB |
显示代码纯文本
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fi("ghillie.in");
ofstream fo("ghillie.out");
int main()
{
int n,a[201]={0},i,j,s=0,d,s1=0,k,a1[201]={0};
int m[10][8]={
{1,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1},
{1,2,4,8,16,32,64,128},
{1,3,9,27,81,243,729,2187},
{1,4,16,64,256,1024,4096,16384},
{1,5,25,125,625,3125,15625,78125},
{1,6,36,216,1296,7776,46656,279936},
{1,7,49,343,2401,16807,117649,823543},
{1,8,64,512,4096,32768,262144,2097152},
{1,9,81,729,6561,59049,531441,4782969}};
fi>>n;
for(i=1;!fi.eof();i++)
{
fi>>a[i];
}
s=i-1;
for(i=1;i<=n;i++)
{
for(j=1;j<=s;j++)
{
if(a[j]==-1)continue;
d=a[j];s1=0;
while(d!=0)
{
s1+=m[d%10][i+1];
d/=10;
}
for(k=1;k<=s;k++)
{
if(a[k]==s1)
{
a1[k]=-1;
}
else
{
if(a1[k]!=-1)a1[k]=a[k];
}
}
}
for(k=1;k<=s;k++)
{
a[k]=a1[k];
}
}
sort(a+1,a+1+s);
for(i=1;i<=s;i++)
{
if(a[i]!=-1)
{
fo<<a[i]<<" ";
}
}
return 0;
}