level 1
Shellot4
楼主
var
i,j,n,k:longint;
bo:boolean;
t:int64;
function exp(b,p:longint):longint;
begin
exp:=1;
while p>0 do
begin
if p mod 2 = 1 then exp:=exp*b;
b:=b*b;
p:=p div 2;
end;
end;
begin
read(n);
t:=int64(exp(10,n));
for i:= t div 10 to t-1 do
begin
for j:= 0 to i do
for k:= 2 to int64(trunc(sqrt(i div exp(10,j)))) do
if j mod k = 0 then bo:=true;
if not bo then writeln(i);
bo:=false;
end;
end.
数据范围是1<=n<=8
时间复杂度是指数级的
求dalao如何解决?(最好再优化)
题面:http://hz2hs.openjudge.cn/2017shu/13786/
2017年07月26日 13点07分
1
i,j,n,k:longint;
bo:boolean;
t:int64;
function exp(b,p:longint):longint;
begin
exp:=1;
while p>0 do
begin
if p mod 2 = 1 then exp:=exp*b;
b:=b*b;
p:=p div 2;
end;
end;
begin
read(n);
t:=int64(exp(10,n));
for i:= t div 10 to t-1 do
begin
for j:= 0 to i do
for k:= 2 to int64(trunc(sqrt(i div exp(10,j)))) do
if j mod k = 0 then bo:=true;
if not bo then writeln(i);
bo:=false;
end;
end.
数据范围是1<=n<=8
时间复杂度是指数级的
求dalao如何解决?(最好再优化)
题面:http://hz2hs.openjudge.cn/2017shu/13786/