- Superprime
- 2009-09-10 16:42:18 @
啥叫无效浮点运算?????????????
帮忙看看!!!!!!
program wuye;
var n:longint;
function f(x:longint):boolean;
var i:longint;
begin
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then exit(false);
exit(true);
end;
procedure find(now,k:longint);
begin
if k=n+1 then writeln(now);
if f(now*10+1) then find(now*10+1,k+1);
if f(now*10+3) then find(now*10+3,k+1);
if f(now*10+7) then find(now*10+5,k+1);
if f(now*10+9) then find(now*10+9,k+1);
end;
begin
read(n);
find(2,2);
find(3,2);
find(5,2);
find(7,2);
end.
2 条评论
-
学霸wx LV 7 @ 2016-12-22 11:56:28
是不是因为Pascal不能直接隐式类型转换?
-
2014-10-17 16:10:09@
Program p1359;
const a:array[1..6] of integer=(1,2,3,5,7,9);
var n,i,j:integer;
num:longint;
function check(num:longint):boolean;
var i:integer;
begin
for i:=2 to trunc(sqrt(num)) do
if num mod i=0 then
begin
check:=false;
exit;
end;
if num=1 then begin check:=false;exit;end;
check:=true;
end;
procedure find(num:longint;l:integer);
var i:integer;
begin
if not check(num) then exit;
if l=n then begin
writeln(num);
exit;
end;
for i:=1 to 6 do find(num*10+a[i],l+1);
end;
begin
readln(n);
find(0,0);
end.
看看这个
- 1