1
548834
不存在7位数.
汗,都懒得写代码了.......... cheat了一个威望,哈.....
应该从1000000-9999999之间搜索吧,从1开始范围也太广了.如果方便,贴出代码看看.
之所以从1开始搜索也是为了验证一下程序,
代码:
#include<stdio.h>
#define power(t) t*t*t*t*t*t
const int M=1;
const int N=10000000;
int vaild(int m)
{
int r,t=m,sum=0;
while(m)
{
r=m%10;
m/=10;
sum+=power(r);
}
return sum==t?1:0;
}
int main()
{
int i;
char ch;
for(i=M;i<N;i++)
{
if(vaild(i))printf("%d\n",i);
}
ch=getchar();
return 0;
}
用DELPHI写了一个:
function cacl(a: integer): integer; //求六次方的函数
var
b:integer;
begin
asm
xor eax,eax
xor esi,esi
mov eax,a
mov ecx,eax
mov esi,$6
@:
imul eax,ecx
dec esi
jne @
mov b,eax
end;
Result := b;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s,i:integer;
c:string;
d:string;
begin
for i := 1000000 to 9999999 do
begin
d:=inttostr(i);
s1:=cacl(strtoint(midstr(d,1,1)));
s2:=cacl(strtoint(midstr(d,2,1)));
s3:=cacl(strtoint(midstr(d,3,1)));
s4:=cacl(strtoint(midstr(d,4,1)));
s5:=cacl(strtoint(midstr(d,5,1)));
s6:=cacl(strtoint(midstr(d,6,1)));
s7:=cacl(strtoint(midstr(d,7,1)));
s:=s1+s2+s3+s4+s5+s6+s7;
if s=i then break ;
edit1.Text:=inttostr(i);
end;
end;
end.
不知道行不行,但是计算奇慢.
[此贴子已经被作者于2006-8-29 11:22:15编辑过]