/ Vijos /

用户

个人简介


Var
        n,m,num,i:longint;
        a:array[1..20]of longint;

Function pd(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 dfs(x,y,sum:longint);
Var
        i:longint;
Begin
        if y=m then
        begin
                if pd(sum) then
                        inc(num);
                exit;
        end;

        for i:=x+1 to n do
                dfs(i,y+1,sum+a[i]);
End;

Begin
//assign(input,'1.in');reset(input);

         readln(n,m);
         for i:=1 to n do
                read(a[i]);
         dfs(0,0,0);
         writeln(num);
         readln;

close(input);
End.