- 捕风捉影
- 2009-10-08 19:44:49 @
program bufengzhuoying;
var
b,c,d,e,n,i,j:longint;
s:string;
a,s1:array[0..99999999]of longint;
begin
readln(b,c);
for d:=b to c do
begin
str(d,s);
for e:=length(s) downto 1 do
n:=n*10+ord(s[e])-48;
if d=n then
begin
a[a[0]+1]:=d;
a[0]:=a[0]+1;
end;
n:=0;
end;
for d:=1 to a[0] do
begin
n:=trunc(sqrt(a[d]));
for e:=2 to n do
if a[d] mod e=0 then
j:=1;
if j1 then
begin
s1[s1[0]+1]:=a[d];
s1[0]:=s1[0]+1;
end;
j:=0;
end;
for d:=1 to s1[0] do
writeln(s1[d]);
end.
2 条评论
-
donghexin LV 8 @ 2009-10-11 20:59:23
program da;
var
a:array[1..100000]of longint;
s:string;
i,j,k,l,m,n,o,p:longint;
f:boolean;
begin
read(m,n);
if (m=5)then writeln('5');
if (m=7)then writeln('7');
if (m=11)then writeln('11');
for i:=10 to 99 do begin f:=true;
k:=i;
str(k,s);
s:=s+s[1];
val(s,k,j);
for j:=2 to trunc(sqrt(k)) do
if k mod j =0 then f:=false;
if (f)and(m=k) then writeln(k);
end;
for i:=100 to 999 do begin f:=true;
str(i,s);
s:=s+s[2];
s:=s+s[1];
val(s,k,j);
for j:=2 to trunc(sqrt(k)) do
if k mod j =0 then f:=false;
if (f)and(m=k) then writeln(k);
end;for i:=1000 to 9999 do begin f:=true;
str(i,s);
s:=s+s[3];
s:=s+s[2];
s:=s+s[1];
val(s,k,j);
for j:=2 to trunc(sqrt(k)) do
if k mod j =0 then f:=false;
if (f)and(m=k) then writeln(k);
end;
end. -
2009-10-08 20:12:13@
5到1亿,判素数你还想逐一枚举过啊,得优化
- 1