hys_bj
幼苗
共回答了22个问题采纳率:90.9% 举报
var
a,k,i,w,sum,x:longint;
s:array[1..8363]of longint;
e:array[1..8363]of boolean;
st:string;
b:array[1..5]of char;
flag:array[0..9]of boolean;
c:array[1..120]of string;
procedure search(depth:integer);
var i,t:integer;
begin
if(depth>a) then
begin
inc(x);
for i:=1 to a do c[x]:=c[x]+b[i];
exit;
end;
for i:=1 to a do
if flag[i]=false then
begin
b[depth]:=st[i];
flag[i]:=true;
search(depth+1);
flag[i]:=false;
end;
end;
function erfen(o:string):boolean;
var
m,head,tail,j:longint;
begin
val(o,m);
head:=1;
tail:=w;
j:=trunc((head+tail)/2);
repeat
if s[j]=m then exit(false)
else
if s[j]>m then
begin tail:=j-1; j:=trunc((head+tail)/2) end
else if s[j]tail);
exit(true);
end;
procedure checks(w:longint);
var
i,j:longint;
begin
for i:=1 to w do
begin
str(s[i],st);
x:=0;
search(1);
for j:=1 to k do
if erfen(c[j]) then e[i]:=false;
for j:=1 to k do
c[j]:='';
end;
end;
function check(w:longint):boolean;
var
i:longint;
begin
for i:=2 to round(sqrt(w)) do
if w mod i =0 then exit(false);
exit(true);
end;
procedure trys(a:longint);
var
i,j,head,tail:longint;
begin
tail:=9;
head:=1;
w:=0;
for i:=1 to a-1 do
begin
head:=head*10;
tail:=tail*10+9;
end;
for i:=head to tail do
if check(i) then begin inc(w);s[w]:=i; end;
checks(w);
for i:=1 to w do
if e[i] then inc(sum);
write(sum);
end;
begin
k:=1;
fillchar(e,sizeof(e),true);
readln(a);
for i:=2 to a do
k:=k*i;
if a=1 then write(4)
else if a
1年前
9