谁能帮我解决一道信息问题我的QQ号是849067563

来源:百度知道 编辑:UC知道 时间:2024/05/23 14:47:17
program hbpl;
var
a:array[1..10]of longint;
b:array[1..10]of boolean;
m,n,x,f:int64;
input,output:text;
function ss(y:longint):boolean;
var
i:longint;
begin
for i:=2 to trunc(sqrt(y)) do
if y mod i =0 then begin
ss:=false;
break;end;
end;
procedure work(s:longint);
var
i,j,l,t:longint;
begin
if s>m then begin
l:=0;t:=1;
for i:=m downto 1 do begin
l:=a[i]*t+l;
t:=t*10;end;
if ss(l) then begin
x:=x*l;
inc(f);end;end
else
for j:=1 to n do
if b[j] then begin
a[s]:=j;
b[j]:=false;
work(s+1);
b[j]:=true;end;
if s>m then write(output,'');
end;
begin
assign(input,'input.txt');reset(input);
assign(output,'output.txt');rewrite(output);
read(input,m,n);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),true);
x:=1;f:=0;
work(1);
if f=0 then write(output,0

o(∩_∩)o...哈哈,只懂得C/C++的,你这个不是,帮不上忙了!

program hbpl;

uses Windows,SysUtils;

function isprime(n: longint): boolean;
var
i, j: longint;
begin
Result := true;
for i := 2 to trunc(sqrt(n)) do
if n mod i = 0 then
begin
Result := false;
exit;
end;
end;

function A(a,b:integer):Integer;
var i,j,k,num,last:Integer;
begin
test:=0;
num := 0;
last:= 0;
Result := 0;
for i:=1 to a do begin
k:=i*10;
for j:=1 to b do begin
num := k+j;
if not isprime(num) then Continue;
Result := Result + num*last;
last := num;
end;
end;
for j:=1 to a do begin
k:=j*10;
for i:=1 to b do begin
num := k+i;
if not isprime(num) then Continue;
Result := Result + num*last;
last := num;
end;
end;