- 选数
- 2015-09-27 14:56:08 @
var n,k,i,ans:longint;
x:array[1..20] of longint;
function sushu(n:longint):boolean;
var i:longint;
begin
if n<2 then begin
sushu:=false;exit;end
else
if n=2 then
sushu:=true
else
begin
sushu:=true;
for i:=2 to round(sqrt(n)) do
if (n mod i)=0 then sushu:=false;
end;
end;
procedure xuanze(d,s,g:longint);
var i:longint;
begin
if g=0 then
begin
if sushu(s) then inc(ans); exit;
end;
for i:=d to n do xuanze(i+1,s+x[i],g-1);
end;
begin
ans:=0;
readln(n,k);
for i:=1 to n do read(x[i]);
xuanze(1,0,k);
writeln(ans);
end.
0 条评论
目前还没有评论...