- 捕风捉影
- 2009-09-07 20:38:44 @
只过了四个点;
先判断是否为素数,是的再判断是否为回文数。
也只有这样了啊。。。(该不会应该先回文数再素数吧?!)
program p1042;
var
m,n,i:longint;
flag:boolean;
procedure sushu(p:longint);
var
j1:longint;
begin
for j1:=2 to round(sqrt(p)) do
if (p mod j1)=0 then
flag:=false;
end;
procedure hws(q:longint);
var
j:string;
flag1:boolean;
k1,k2:longint;
begin
flag1:=true;
str(q,j);
k2:=length(j);
for k1:=1 to (length(j)div 2) do begin
if (j[k1]j[k2]) then begin
flag1:=false;
break;
end;
k2:=k2-1;
end;
if flag1=true then writeln(q);
end;
begin
read(m,n);
for i:=m to n do
begin
flag:=true;
sushu(i);
if flag=true then
hws(i);
end;
end.
5 条评论
-
winter-L LV 7 @ 2009-09-08 20:46:47
嗯,打表过了。
就是这题不打表就不行啊?!(第十个数据究竟是啥?) -
2009-09-08 18:45:10@
不好意思啊。请问。。。。打表是什么意思?(不要鄙视我。。⊙﹏⊙)
-
2009-09-07 20:58:13@
打表
打表
-
2009-09-07 20:48:09@
我已经弄到最优了,还弄了两个BREAK,可是最后一个点依旧过不了。。90分
program p1042;
var
m,n,i:longint;
flag:boolean;
procedure sushu(p:longint);
var
j1:longint;
flag1:boolean;
begin
flag1:=true;
for j1:=2 to round(sqrt(p)) do
if (p mod j1)=0 then begin
flag1:=false;
break;
end;
if flag1=true then writeln(p);
end;
procedure hws(q:longint);
var
j:string;
k1,k2:longint;
begin
str(q,j);
k2:=length(j);
for k1:=1 to (length(j)div 2) do begin
if (j[k1]j[k2]) then begin
flag:=false;
break;
end;
k2:=k2-1;
end;
end;
begin
read(m,n);
for i:=m to n do
begin
flag:=true;
hws(i);
if flag=true then
sushu(i);
end;
end. -
2009-09-07 20:42:25@
我反过来试过,90分,最后一个过不了。。。
- 1