1
548834
不存在7位数.

汗,都懒得写代码了.......... cheat了一个威望,哈.....
2006-08-28 22:54
应该从1000000-9999999之间搜索吧,从1开始范围也太广了.如果方便,贴出代码看看.
2006-08-29 07:09
应该从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;
}

2006-08-29 10:44
用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编辑过]
2006-08-29 11:16
2006-08-29 11:25
是不是这种的:
10进制的N的6次方=16进制N的6次方???
是不是我的理解有点错误?
2006-08-29 11:27
已经搞定:
1741725
4210818
9800817
9926315
[此贴子已经被作者于2006-8-29 12:21:45编辑过]
2006-08-29 11:54
已经搞定:
1741725
4210818
9800817
9926315
汗,你求的是每个数字的7次方吧,那干嘛题目说6次方

2006-08-29 13:11
.谢谢你的热心帮忙,你的那段代码写的非常好,而且速度很快.[此贴子已经被作者于2006-8-29 14:45:03编辑过]
2006-08-29 14:25