记录编号 69955 评测结果 AAAAAAAAAA
题目名称 [金陵中学2007] 吉祥数 最终得分 100
用户昵称 GravatarNARUTO 是否通过 通过
代码语言 C++ 运行时间 0.002 s
提交时间 2013-09-22 19:31:30 内存使用 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,ss=0,k,b[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];ss=0;
			while(d!=0)
			{
				ss+=m[d%10][i+1];
				d/=10;
			}
			for(k=1;k<=s;k++)
			{
				if(a[k]==ss)
					b[k]=-1;
				else
				{
					if(b[k]!=-1)b[k]=a[k];
				}
			}
		}
		for(k=1;k<=s;k++)
			a[k]=b[k];
	}
	sort(a+1,a+1+s);
	for(i=1;i<=s;i++)
	{
		if(a[i]!=-1)
			fo<<a[i]<<" ";
	}
	return 0;
}