```cpp
var n,k,i,j,s,sum:longint;
a:array [1..20] of longint;
b:array [1..20] of boolean;
c:array [1..200] of longint;
function pd(ss:longint):boolean;
var i:longint;
f:boolean;
begin
pd:=true;
for i:=2 to trunc(sqrt(s)) do
if ss mod i=0 then pd:=false;
end;
procedure try(t,x:longint);
var i,j,l:longint;
f:boolean;
begin
for i:=x+1 to n do
if b[i] then
begin
b[i]:=false;
inc(s,a[i]);
if (t=k) then
begin
if (pd(s))then inc(sum);
end else try(t+1,i);
b[i]:=true;
dec(s,a[i]);
end;
end;
begin
read(n,k);
sum:=0;
for i:=1 to n do
read(a[i]);
fillchar(b,sizeof(b),true);
fillchar(c,sizeof(c),0);
try(1,0);
write(sum);
end.
```
by 姚文涛 @ 2016-07-04 14:17:31